Files
python/pythonProject/流程语句/if/双分支结构2.py
T
2026-10-09 15:50:18 +08:00

4 lines
256 B
Python

num=eval(input("请输入幸运数字:"))
print('输入了幸运数字1') if num==1 else print('输入了其他幸运数字')
# 这是 Python 的 条件表达式(三元运算符)
# 值A if 条件 else 值B 条件为真返回值A,否则返回值B。