小编use*_*941的帖子

Python字典转换为小写?

我有这个需要转换为小写的Python字典.字典由需要对不区分大小写输入的数据组成,例如,它适用于resp ='GBR'或'gbr'.希望我在这里有意义.任何帮助将非常感谢!

resp = raw_input('Which country is ' + record['name'] + ' in? ')
        print " "
        valid = {'GBR': ['GBR',
                        'United Kingdom',
                        'UK',
                        'Great Britain and Northern Island',
                        'GB'
                        ],
                'IRL': ['IRL',
                        'Eire',
                        'Republic of Ireland'
                        ]
            }
        if resp in valid[record['sov']]:
            answ = 'Yes, ' + record['name'] + ' is in the ' + resp
Run Code Online (Sandbox Code Playgroud)

python dictionary lowercase uppercase

3
推荐指数
1
解决办法
3933
查看次数

标签 统计

dictionary ×1

lowercase ×1

python ×1

uppercase ×1