📜  python list Comprehensions - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:48.632000             🧑  作者: Mango

代码示例6
# List 
# new_list[ for  in  if ]
a = [i for i in 'hello']                  # ['h', 'e', 'l', 'l', '0']
b = [i*2 for i in [1,2,3]]                # [2, 4, 6]
c = [i for i in range(0,10) if i % 2 == 0]# [0, 2, 4, 6, 8]