Discuss / Python / 先取正确数列,再变小写

先取正确数列,再变小写

Topic source

L2 = [s.lower() for s in [x for x in L1 if isinstance(x, str)]]

先用isinstance生成一个不包含数字和None的list,然后再对这个list进行小写变化

乃木坂骑

#2 Created at ... [Delete] [Delete and Lock User]

可以一步完成:

L2 = [s.lower() for s in L1 if isinstance(s, str)]

  • 1

Reply