python实现创建新列表和新字典,并使元素及键值对全部变成小写

时间:2022-11-02 09:15:29

如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
lists = ['tom','Jack','luCy','lily','jErry','anna']
dics = {'jack':'python','Lucy':'jaVa','jeRry':'rUby','lily':'c#',}
 
 
 
new_lists = []
for i in lists:
    new_lists.append(i.lower())
print(new_lists)
 
 
 
new_dics = {}
for i,j in dics.items():
    new_dics[i.lower()] = j.lower()
print(new_dics)

以上这篇python实现创建新列表和新字典,并使元素及键值对全部变成小写就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/weixin_42382856/article/details/80568320