国产日韩欧美一区二区三区综合,日本黄色免费在线,国产精品麻豆欧美日韩ww,色综合狠狠操

極客小將

您現(xiàn)在的位置是:首頁 » python編程資訊

資訊內(nèi)容

python如何判斷是否為整數(shù)

極客小將2021-03-13-
簡介python判斷是否為整數(shù)的方法:1、使用【type()】函數(shù)判斷,代碼為【type(name,bases,dict)】;2、使用【isinstance()】函數(shù)判斷,代碼為【isinstance(object,classinfo)】。本教程操作環(huán)境:windows7系統(tǒng)、python3.9版,DE

python判斷是否為整數(shù)的方法:1、使用【type()】函數(shù)判斷,代碼為【type(name, bases, dict)】;2、使用【isinstance()】函數(shù)判斷,代碼為【isinstance(object,classinfo)】。MWz少兒編程網(wǎng)-https://www.pxcodes.com

MWz少兒編程網(wǎng)-https://www.pxcodes.com

本教程操作環(huán)境:windows7系統(tǒng)、python3.9版,DELL G3電腦。MWz少兒編程網(wǎng)-https://www.pxcodes.com

python判斷是否為整數(shù)的方法:MWz少兒編程網(wǎng)-https://www.pxcodes.com

1、使用type()函數(shù)判斷MWz少兒編程網(wǎng)-https://www.pxcodes.com

type()函數(shù)語法:MWz少兒編程網(wǎng)-https://www.pxcodes.com

type(object) type(name, bases, dict)

type() 函數(shù)如果你只有第一個參數(shù)則返回對象的類型,三個參數(shù)返回新的類型對象。MWz少兒編程網(wǎng)-https://www.pxcodes.com

示例:MWz少兒編程網(wǎng)-https://www.pxcodes.com

>>> type(1) <type 'int'>

2、使用isinstance()函數(shù)判斷MWz少兒編程網(wǎng)-https://www.pxcodes.com

isinstance()方法的語法:MWz少兒編程網(wǎng)-https://www.pxcodes.com

isinstance(object, classinfo)

如果對象的類型與參數(shù)二的類型(classinfo)相同則返回 True,否則返回 False。MWz少兒編程網(wǎng)-https://www.pxcodes.com

示例:MWz少兒編程網(wǎng)-https://www.pxcodes.com

>>>a = 2 >>> isinstance (a,int) True

相關(guān)免費學(xué)習(xí)推薦:python視頻教程MWz少兒編程網(wǎng)-https://www.pxcodes.com

以上就是python如何判斷是否為整數(shù)的詳細內(nèi)容,更多請關(guān)注少兒編程網(wǎng)其它相關(guān)文章!MWz少兒編程網(wǎng)-https://www.pxcodes.com

預(yù)約試聽課

已有385人預(yù)約都是免費的,你也試試吧...

主站蜘蛛池模板: 榕江县| 万安县| 娄烦县| 久治县| 林芝县| 新郑市| 合山市| 土默特右旗| 华容县| 双柏县| 清涧县| 高安市| 平泉县| 宣武区| 芦山县| 崇阳县| 柳江县| 富裕县| 阿拉善右旗| 额尔古纳市| 彝良县| 呼伦贝尔市| 花莲县| 山丹县| 古蔺县| 宁阳县| 临武县| 丹东市| 玛曲县| 阿克苏市| 桐城市| 新兴县| 南宫市| 霍州市| 阜平县| 阿鲁科尔沁旗| 喀什市| 蓬莱市| 会理县| 西林县| 衡东县|