Loading

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')





posted @ 2020-02-16 14:24  云起时。  阅读(162)  评论(0编辑  收藏  举报