python运算符in和not in,,1.in: 表示连续
python运算符in和not in,,1.in: 表示连续
1.in: 表示连续的字符串或单个字符包含
举例
name = ‘张三四‘
# name里包含张,结果输出inif ‘张‘ in name : print(‘in‘)else: print(‘error‘)
# name里不包含张四,结果输入errorif ‘张四‘ in name: print(‘in‘)else: print(‘error‘)
2.not in
# name里不包含张四,结果输出1if ‘张四‘ not in name: print(‘1‘)else: print(‘2‘)
python运算符in和not in
评论关闭