Discuss / Python / #先用isinstance判断是否是字符串,然后用lower方法转化成小写

#先用isinstance判断是否是字符串,然后用lower方法转化成小写

Topic source

祝新新ZXY

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

L1 = ['Hello', 'World', 'IBM', 'Apple'] L2 = ['Hello', 'World', 18, 'Apple', None]

for i in L1: if isinstance(i,str): print(i.lower()) else: print("False") for s in L2: if isinstance(s,str): print(s.lower()) else: print("__False")


  • 1

Reply