Python不区别字符串大小写的列表比较法

 

一开始想这样写,结果报了索引错误

 

后来改正:

if user_name.lower() in [names.lower() for names in names]:

我觉得应该是in后面应该跟列表,而我这种写法对整个列表使用.lower是错误的,因为.lower应该对某一字符串使用

posted @ 2019-01-28 21:47  swenw  阅读(2128)  评论(0编辑  收藏  举报