python 断言

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


aa = "asd"
bb = 12

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

assert type(bb) is str
print(bb)
原文地址:https://www.cnblogs.com/gaizhongfeng/p/7975772.html