python - 为什么断言没有像预期那一天报错

查看:108
本文介绍了python - 为什么断言没有像预期那一天报错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

age=10
assert 0<age<10
age=-1
assert 0<age<10,'the age must be realistic'

解决方案

第2行就结束了,没有到第4行

age=10
assert 0<age<10, 'the age is not in 1~9'
age=-1
assert 0<age<10,'the age must be realistic'

这篇关于python - 为什么断言没有像预期那一天报错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆