python两层嵌套 [i for x in L for i in x]
大家都见过 [x for x in L ]
可能没见过 [i for x in L]
positive_pairs = [(1,2),(3,4),(5,6),(7,8),(70,80)]
negtive_pairs = [(10,20),(30,40),(50,60),(70,80)]
print([i for x in positive_pairs])
结果: [range(0, 4), range(0, 4), range(0, 4), range(0, 4), range(0, 4)]
print(type([i for x in positive_pairs][0]))
结果:
相当于啥也不是!!!
一定没见过 [i for x in L for i in x]
positive_pairs = [(1,2),(3,4),(5,6),(7,8),
共有 0 条评论