assert語句:
用以檢查某一條件是否為True,若該條件為False則會給出一個AssertionError。
用法:
assert type(x)=int and x>=0
如果不滿足后面的expression,則會彈出
Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> assert type(n)==int and n>0 AssertionError
assert語句:
用以檢查某一條件是否為True,若該條件為False則會給出一個AssertionError。
用法:
assert type(x)=int and x>=0
如果不滿足后面的expression,則會彈出
Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> assert type(n)==int and n>0 AssertionError
本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。