功能:
对一个列表中的字符串小写
代码一:
l = ['Hello','World',20,'IBM','Apple'] J = [] for s in l: if isinstance(s,str): s.lower() J.append(s.lower()) else: s J.append(s) print J
M = ['Hello','World',20,'IBM','Apple'] N = [h.lower() if isinstance(h,str) else h for h in M] print N
写代码一定要简洁,记住这点,你才能写出高质量的代码!
原文:http://blog.csdn.net/yifei325325/article/details/40928931