第二组 (4个,min,max,all,any)
number_list = [11,22,33,1,0,19,18]
ret = min(number_list)
print (ret) #0
number_list = [11,22,33,1,0,19,18]
ret = max(number_list)
print (ret) #22
- all 判断内部元素转换成布尔值,是否都是True
data_list = [11,22,-1,99,0] #有一个为False为False,全部为True时,才为True
ret = all(data)
print(ret) #False
#all 使用案例
user = input('用户名:').strip() #去除输入空格
pwd = input('密码:').strip() #去除输入空格
if all ([user,pwd]):
print('未包含空格')
else:
print('用户名或密码错误')
- any 判断,只要存在True(内部存在类型转换),整体就是True
v1 = any([11,22,3])
v2 = any([11,22,0])
v3 = any([11,22,'',3])
v4 = any([None,"",0])