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删除。