python列表每个元素同增同减和列表元素去空格的实例
如下所示: import os var = [1, 2, 3] data = [x*2 for x in var] print (data) two = [[i, i**2] for i in var] print (two) three = [[i, i+i, i**3] for i in var] print (three) fruit = [' banana', ' loganberry ', 'passion fruit '] strip_fruit = [one.strip() for one in fruit] print (strip_fruit) 以上这篇python列表
用户评论