a = 'py' in 'python' b = 'py' not in 'python' print(a)
print(b)
in :判断一个前面一个字符串中的字符是否完整的出现在后面的字符串中,如果完整的出现过则输出True,否则输出False
not in :和in相反,如果没有完整出现过则输出True,否则输出False
比较运算:
==
>
<
>=
<=
!= 不等于
<> 不等于
逻辑运算:
and:用来比较多个比较运算,真真为真,真假为假,假假为假
a = True and True b = True and False c = False and True d = False and False print(a)#结果为真 print(b)#结果为假 print(c)#结果为假 print(d)#结果为假
or:和and一样是用来比较多个比较运算,但是,真真为真,真假为真,假假为假
a = True or True b = True or False c = False or True d = False or False print(a)#结果为真 print(b)#结果为真 print(c)#结果为真 print(d)#结果为假
not:如果逻辑运算为假则返回真,真则返回假
a = not(True) b = not(False) print(a)#结果为假 print(b)#结果为真
a = '123' print(type(a),a) b = int(a) print(type(b),b)
int():强制转换成数字类型
type():返回输入值的类型
print(int('0111',base=2))
int('',base=):把输入的值转换成二进制,base里面的值会改变他转换成的值,base的范围是2<=base<=36