Python零碎知识(11):assert用法
生活随笔
收集整理的這篇文章主要介紹了
Python零碎知识(11):assert用法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
參考:
http://www.cnblogs.com/herbert/archive/2013/01/12/2857233.html
assert語句,如果沒記錯,這個東西在C或者C++里面也有的。屬于短小的斷言。下面的是來自python help document的說明:
Assert statements are a convenient way to insert debugging assertions into a program:
assert語句是一種插入調試斷點到程序的一種便捷的方式。
assert語句的使用格式
assert expression這個語句是等價于下面的個句式:
if __debug__:if not expression:總結
以上是生活随笔為你收集整理的Python零碎知识(11):assert用法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Python安装模块出错(ImportE
- 下一篇: python小实验(1):字符串处理