列表的通用操作 1、+和* a、+可以将两个列表拼接为一个列表
stus=['张明','花花','量子','唐山','陆路','七七','画画','小仙']
tech=['张小龙','李晓丽','诺诺','吉安娜']
print(stus+tech)
结果截图:  b、*可以将列表重复指定次数
stus=['张明','花花','量子','唐山','陆路','七七','画画','小仙']
tech=['张小龙','李晓丽','诺诺','吉安娜']
print(stus*1)
print(tech*2)
结果截图:  2、in和not in in:用来检查指定元素是否存在列表中,如果存在,返回true,不存在,返回false
stus=['张明','花花','量子','唐山','陆路','七七','画画','小仙']
tech=['张小龙','李晓丽','诺诺','吉安娜']
print(str('张明'in stus) +'代表张明存在列表中')
print(str('环境' in stus)+'代表环境不存在列表中')
结果截图 
not in:用来检查指定元素是否不存在列表中,如果不存在,返回true;存在,返回false
stus=['张明','花花','量子','唐山','陆路','七七','画画','小仙']
tech=['张小龙','李晓丽','诺诺','吉安娜']
print(str('张明'not in stus) +'代表张明存在列表中')
print(str('环境'not in stus)+'代表环境不存在列表中')
结果截图: 
3、min()获取列表中的最小值,max()获取列表中的最大值
stus=[1,7,8,9]
print('最小为'+str(min(stus)))
print('最大为'+str(max(stus)))
结果截图: 
进阶
stus=[1,7,8,9]
print('最小为'+str(min(stus)))
print('最大为'+str(max(stus)))
print('最小的索引为'+str(stus.index(min(stus))))
print('最大的索引为'+str(stus.index(max(stus))))
结果截图: 
|