if Python · 关键字
根据条件真假决定走哪条路,像红绿灯:条件为真就通行,为假就停。
怎么用
if 条件:
小例子
age = 18
if age >= 18:
print('成年')
运行结果
成年
官方文档:https://docs.python.org/zh-cn/3/tutorial/controlflow.html#tut-if
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条if Python · 关键字根据条件真假决定走哪条路,像红绿灯:条件为真就通行,为假就停。
if 条件:
age = 18
if age >= 18:
print('成年')
成年
官方文档:https://docs.python.org/zh-cn/3/tutorial/controlflow.html#tut-if
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条