L1 = ['Hello','World',18,'Apple',None] L2 = [x for x in L1 if (isinstance(x,str) == True) ] print(L2)
还要变小写额
犯了个低级错误,True给我写成了true,我说怎么一直报错,明明逻辑走得通,还是基础不够牢靠
没有必要添加==True
Sign in to make a reply
君临妃子笑
L1 = ['Hello','World',18,'Apple',None] L2 = [x for x in L1 if (isinstance(x,str) == True) ] print(L2)