如何在 List Comprehension 中使用 python 类型?我可以吗?
>>> ll
[1, 2, 5, 'foo', 'baz', 'wert']
>>> [x for x in ll ]
[1, 2, 5, 'foo', 'baz', 'wert']
>>> [x for x in ll if type(x) == 'int']
[]
>>> [x*20.0 for x in ll if type(x) == 'int']
[]
>>> type(ll[0])
<type 'int'>
寻找 :[20, 40, 100, 'foo', 'baz', 'wert']