元组推导式 #普通的元组推倒式 tp =(1,2,3,4,5,6,77,66) newtp = (i for i in tp ) print(newtp) #生成器需要遍历查看 for i in newtp: print(i) #带有判断条件的元组推导式 newtp = (i * 10 for i in tp if i >=100) print(newtp) #s生成器需要遍历查看 for i in newtp: print(i) #多循环带有判断条件的元组推导式 girls = ('中举','采集','南山') boys = ('素食','树勋','苏泽') newtp =(g +'--'+b for g in girls for b in boys if girls.index(g)==boys.index(b)) print(newtp) #生成器需要遍历查看 for i in newtp: print(i)
內置函數操作筆記-元组
猜你喜欢
转载自blog.csdn.net/dqshjq/article/details/80790633
今日推荐
周排行