有時候我們需要知道variable的數據類型,在python中有內置函數type可以獲取variable的數據類型
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'>
以上內容為大家介紹了python培訓之如何查看變量的類型,希望對大家有所幫助,如果想要了解更多Python相關知識,請關注IT培訓機構:千鋒教育。