目录
1. if 基本语句
if 条件:
if语句块
else:
else语句
2. if elif嵌套结构
if 条件:
if语句块
elif 条件:
elif语句块
else:
else语句块
3. 例子
源码:
a = input("Input number1:\n")
a = int(a);
b = input("Input number2:\n")
b = int(b);
if (a >= b):
if (a > b):
print("a(%d) > b(%d)" % (a, b));
else:
print("a(%d) = b(%d)" % (a, b));
else:
print("a(%d) < b(%d)" % (a, b));
结果:
Input number1:
1
Input number2:
2
a(1) < b(2)
来源:CSDN
作者:JDSH0224
链接:https://blog.csdn.net/chenliang0224/article/details/103745791