assert语句(assert用来判断语句的真假)

# -*- coding: utf-8 -*-
#python 27
#xiaodeng
#Python学习手册 868
#assert语句(assert用来判断语句的真假)



#案例
mylist=['item']
assert len(mylist)>=1
mylist.pop()
assert len(mylist)>=1
#
'''
Traceback (most recent call last):
  File "C:\Users\Administrator\Desktop\my.py", line 12, in <module>
    assert len(mylist)>=2
AssertionError
'''

 

posted @ 2015-10-30 15:05  Xiao|Deng  阅读(657)  评论(0编辑  收藏  举报