求解怎么将非字符串不变成字符串保存在新list里呢?
Topic source比如这样 L3 = [] for l in L: if isinstance(l,str): L3.append(l.lower()) else: L3.append(l) print(L3)
[x.lower() for x in L1 if isinstance(x,str)] + [x for x in L1 if not isinstance(x,str)]
- 1
比如这样 L3 = [] for l in L: if isinstance(l,str): L3.append(l.lower()) else: L3.append(l) print(L3)
[x.lower() for x in L1 if isinstance(x,str)] + [x for x in L1 if not isinstance(x,str)]
大曾哥顶天立地
求助大神... 输出结果是L2 = ['hello', 'world', 18, 'apple', None],只有字符串变。