码迷,mamicode.com
首页 > 编程语言 > 详细

Python3 断言

时间:2018-10-14 19:19:36      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:pytho   数据   utf-8   出错   usr   断言   int   python   pre   

#!/usr/bin/env python
# _*_ coding:utf-8 _*_
# Author:CarsonLi
‘‘‘
    断言一般用于后面有非常重要的操作,需要使用前面的数据,而且不容许出错
    这里就用的到断言,也可以用
‘‘‘
name="Bert"

assert type(name) is str
print("断言name是str类型")

assert type(name) is not int
print("断言不是int 类型")

  

Python3 断言

标签:pytho   数据   utf-8   出错   usr   断言   int   python   pre   

原文地址:https://www.cnblogs.com/bert227/p/9787016.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!