3、条件语句


3.1、if语句:

1、

if "lc" == "lc":

n2 = input('>>>')

if n2 == "确认":

print('hello')

else:

print('world')

else:

print('error')


2、注意:

n1 = "lc" 赋值

n1 == 'lc' 比较


3、

if 条件1:

pass

elif 条件2:

pass

elif 条件3:

pass

else:

pass

print('end')

#pass 代指空代码,无意义,仅仅用于表示代码块


3.2、and or:

if n1 == "lc" or n2 == "chang":

print('OK')

else:

print('OK')





猜你喜欢

转载自www.cnblogs.com/LiuChang-blog/p/12316740.html