python 断言

# -*- coding: utf-8 -*-
'''
断言可以判断一个变量是否是指定的数据类型,如果不是指定的数据类型就会报错
'''


aa = "asd"
bb = 12

#使用断言
assert type(aa) is str
print(aa)

assert type(bb) is str
print(bb)

 

posted on 2017-12-04 10:10  gaizhongfeng  阅读(156)  评论(0编辑  收藏  举报