assert <表达式>
用于测试<表达式> 的值,如果 <表达式> 的值为 True ,正常通过
如果 <表达式> 的值为 False ,则报错 ‘AssertionError:’
startswith(’ ‘)
举例:tf.version.startswith(‘2.’)
判断 tf 的版本是否是以 ‘2.’开头,如果是,则返回True,否则返回 False
类似有 endswith(’ ')
python中assert的使用
最新推荐文章于 2024-05-21 09:10:56 发布