首页 > 编程语言 > 详细

Python assert(断言)

时间:2019-04-07 22:14:54      阅读:140      评论:0      收藏:0      [点我收藏+]

Python assert(断言)可以分别后面的判断是否正确,如果错误会报错

示例:

a = 1
assert type(a) is int
print(No problem)

输出结果:

No problem

a = 1
assert type(a) is int
print(No problem)

输出结果:

Traceback (most recent call last):
   File "D:/test.py", line 3, in <module>
     assert type(a) is int
AssertionError

Python assert(断言)

原文:https://www.cnblogs.com/dbf-/p/10667344.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!