1.if...elif...else...
代码示例:
test=10
if test>9:
print(1)
elif test>8:
print(2)
elif test>7:
print(3)
else:
print('nothing')
输出代码:
1
本文通过一个简单的 Python 代码示例介绍了 if-elif-else 语句的基本用法。示例中根据变量 test 的值判断并打印不同的结果。此示例有助于初学者理解条件语句的工作原理。
1.if...elif...else...
代码示例:
test=10
if test>9:
print(1)
elif test>8:
print(2)
elif test>7:
print(3)
else:
print('nothing')
输出代码:
1
转载于:https://my.oschina.net/u/3754854/blog/1860224
521
1170

被折叠的 条评论
为什么被折叠?