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 '''
无语言基础,自学python所做的各种笔记,欢迎大牛指点.