Python assert 用法
2017-04-20 21:54
471 查看
Python中assert用来判断语句的真假,如果为假的话将触发AssertionError错误
python help document的解释:
Assert statements are a convenient way to insert debugging assertions into a program:
例:
>>> a = 3
>>> assert a ==3
>>> a = 2
>>> assert a ==3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
例2:
python help document的解释:
Assert statements are a convenient way to insert debugging assertions into a program:
例:
>>> a = 3
>>> assert a ==3
>>> a = 2
>>> assert a ==3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
例2:
相关文章推荐
- assert 用法及获取IP 分类: python基础学习 2013-07-24 16:54 344人阅读 评论(0) 收藏
- python中assert断言的用法
- python assert 断言详细用法格式
- python assert 断言基本用法
- Python 3 小知识 assert用法
- Python 断言assert用法
- python 断言assert用法
- python assert断言的用法
- Python assert断言异常语句格式及用法
- python中assert用法实例分析
- python中assert用法实例分析
- python assert用法
- Python中assert的用法
- python assert用法
- Python基础学习篇—assert用法
- [Python]断言assert的用法
- python中assert、isinstance的用法
- Python-assert的用法
- python中assert用法
- python assert 断言详细用法格式