有時(shí)候我們需要知道variable的數(shù)據(jù)類型,在python中有內(nèi)置函數(shù)type可以獲取variable的數(shù)據(jù)類型
1.在console輸入如下code:
id=1
type(id)
輸出:
《type'int'>
2.在console輸入如下code:
id=1L
type(id)
輸出:
《type'long'>
3.在console輸入如下code:
id=1.0
type(id)
輸出:
《type'float'>
以上內(nèi)容為大家介紹了python培訓(xùn)之如何查看變量的類型,希望對(duì)大家有所幫助,如果想要了解更多Python相關(guān)知識(shí),請(qǐng)關(guān)注IT培訓(xùn)機(jī)構(gòu):千鋒教育。