1、if语句:如果满足条件,则执行A
if 条件 :
A
if __name__ == '__main__':
a = 2
if a == 2:
print('成功了')
2、if-else语句:如果满足条件,则执行A;否则执行B
if 条件 :
A
else:
B
if __name__ == '__main__':
a = 2
if a == 1:
print('成功了')
else:
print('失败了')
3、elif语句
if 条件1:
A
elif 条件2:
B
elif 条件3:
C
if __name__ == '__main__':标签:语句,__,elif,name,python,条件,print,main From: https://blog.51cto.com/u_15694134/6038460
a = 2
if a == 1:
print('A')
elif a == 2:
print('B')
elif a == 3:
print('c')