D10-06 赋值运算 19:00
count = count + 1 等价于 count += 1
count = count *1 等价于 count *=1
count = count -1 等价于 count-=1
count = count /1 等价于count/=1
count = count **1 等价于 count**=1
count = count %1 等价于count%=1
count = count//1 等价于count//=1
算数运算
a = 10*10
赋值运算
a = a + 1
比较运算符
a = 1 > 5
逻辑运算符
a = 1 > 6 or 1==1
成员运算符
a = '刘' in 'ddada'
=======
特别注意
user = 'alex'
pwd = '123'
v = user == 'alex' and pwd =='123' or 1 == 1 and pwd ='9999'
print(v)
输出为True
解析:
and 与 or 没有优先级 v是从前到后运算的
如果and前是假的 认为后面全是假的
如果and前真的 and后 是真的 不管or后面是什么都认为是真的
执行顺序 从签到后
true 遇到 or ==>true
true 遇到 and ==>继续走
false 遇到 or ==>继续走
flase 遇到and ==>false
=========
以下了解就好
num = '0011'
n = int(num,base = 2)
该语句的意思是将num用2进制表现出来
age = 10
r = age.bit_length() #数字的二进制用几位来表示
printI(r)

浙公网安备 33010602011771号