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')
补充内容

1. 算术运算
 print(10 / 3)
 print(10 // 3)
 print(10 ** 2)

2. 赋值运算
增量赋值
 age=18
 age+=1#age=age + 1
 print(age)

 age=18
 age/=3 #age=age/3
 print(type(age))

 age**=2 #age=age**2

 交叉赋值
 x=10
 y=20

 temp=x
 x=y
 y=temp
 x,y=y,x
 print(x,y)

 链式赋值
 x=10
 y=x
 z=y
 x=y=z=10

posted on 2018-11-19 20:42  飞花飘絮  阅读(118)  评论(0编辑  收藏  举报