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列表每个元素同增同减和列表元素去空格的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。