Dictionary to lowercase in Python

前端 未结 12 1092
无人共我
无人共我 2020-12-03 02:10

I wish to do this but for a dictionary:

\"My string\".lower()

Is there a built in function or should I use a loop?

12条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-03 02:53

    In Python 3:

    d = dict()
    d = {k.casefold(): v for k, v in d.items()}
    

提交回复
热议问题