if 怎么写else呢?怎么让不会字符串的,也能显示呢?怎么写呢?
L2 = [s.lower() for s in L1 if isinstance(s,str) else s]
反正这么写是不对了,估计在列表生成式中不支持else语句吧
L2 = [s.lower() if isinstance(k,str) else s for s in L1]
在楼下看到的,搬运上来,试过是正确的
不好意思,isinstance里面应该是s不是k
Sign in to make a reply
Michael_翔_
if 怎么写else呢?怎么让不会字符串的,也能显示呢?怎么写呢?