Discuss / Python / 遍历 L1,用 isinstance 筛选出 L1 中的字符串,再通过 lower()方法将字符串首字母小写

遍历 L1,用 isinstance 筛选出 L1 中的字符串,再通过 lower()方法将字符串首字母小写

Topic source

90丶无悔

#1 Created at ... [Delete] [Delete and Lock User]
L1=['Hello','World',18,'Apple',None]
L2 = [x.lower() for x in L1 if isinstance(x,str)]

  • 1

Reply