发布时间:2019-08-06 13:56:23编辑:auto阅读(1916)
mylist = [-1,0,1,2,3,4];
a = [i*2 for i in mylist];
print(a) #[-2, 0, 2, 4, 6, 8]
a = [i*2 for i in mylist if i>0];
print(a); #[2, 4, 6, 8]
a = [i*2 for i in mylist if i not in [-1,0,1]];
print(a); #[4, 6, 8]
上一篇: python前端HTML和CSS入门
下一篇: 第2课 python数据类型与转换
47494
45795
36793
34326
28969
25599
24444
19611
19112
17634
5467°
6049°
5571°
5639°
6573°
5377°
5378°
5886°
5855°
7172°