标签:you print 运算符 err success 基本 比较运算符 word 逻辑
01 比较运算符
> >=
< <=
==
!=
print(10 != 11)
了解
x=None
print(x == None)
print(x is None)
l1=[‘abc‘,1,[‘a‘,‘b‘,‘c‘]]
l2=[‘abc‘,‘aa‘,]
print(l2 > l1)
02 逻辑运算符
and:连接左右两个条件,只有两个条件同时成立时and运算的结果为True
print(10 > 9 and 3 > 2 and ‘egon‘ == ‘egon‘ and True)
or:连接左右两个条件,两个条件成立任意一个or运算的结果就为True
print(False or False or True or False or 3 > 10)
res=(True or (False and True)) or ((False or True) and False)
res=(True or False) or (True and False)
res=True or False
print(res)
not
print(not 10 > 3)
x=None
print(not x is None)
print(x is not None)
age1=18
age2=19
print(age2 is not age1)
name_bk=‘egon‘
pwd_bak=‘123‘
name=input(‘please input your name: ‘)
pwd=input(‘please input your password: ‘)
if name == name_bk and pwd == pwd_bak:
print(‘login successfull‘)
print(‘login successfull‘)
print(‘login successfull‘)
print(‘login successfull‘)
print(‘login successfull‘)
else:
print(‘username or password error‘)
基本运算符
标签:you print 运算符 err success 基本 比较运算符 word 逻辑
原文地址:https://www.cnblogs.com/martin-wang/p/9985469.html