L = ['Hello', 'World', 18, 'Apple', None]
print([s.lower() if isinstance(s,str) else s for s in L ] )
我这么写的时候列表生成式只回报了这个
<generator object <genexpr> at 0x000002224230F548>
漏打了[]……
Sign in to make a reply
tycoonBrain
L = ['Hello', 'World', 18, 'Apple', None]
print([s.lower() if isinstance(s,str) else s for s in L ] )