免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
怎么判斷數(shù)據(jù)類型
-----------------------------------------------------------------------------------------------
#!/usr/bin/python
# -*- coding: UTF-8 -*-
a,b,c,d=20,5.5,True,4+3j
print(type(a),type(b),type(c),type(d))
#(<type 'int'>, <type 'float'>, <type 'bool'>, <type 'complex'>)
----------------------------------------------------------------------------------------
#!/usr/bin/python
# -*- coding: UTF-8 -*-
print(100,type(100))  #(100, <type 'int'>)
print('100',type('100'))       #('100', <type 'str'>)
----------------------------------------------------------------------------------------
此外還可以用 isinstance 來判斷:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
a = 111
print(isinstance(a, int))#True
----------------------------------------------------------------------------------------
綜合:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
class A:
    pass

class B(A):
    pass
print(isinstance(A(), A))    # returns True
print(type(A()) == A )      # returns False
print(isinstance(B(), A))    # returns True
print(type(B()) == A)       # returns False
               



分享知識,分享快樂!希望中國站在編程之巔!

               ----

公眾微信號:rsgz520

360圖書館館號:rsgz002.360doc.com
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Python 條件語句
Python 函數(shù)
python
Python3學(xué)習(xí)(8)--迭代,可迭代的和迭代器
python3小程序示例,程序中的經(jīng)典(一)
Python 3 教程一:入門
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服