Python iso代码不区分大小写的语言?

Python iso代码不区分大小写的语言?,python,Python,有没有办法简化以下内容: >>> pycountry.languages.get(name='english') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/Python/2.7/site-packages/pycountry/db.py", line 114, in get return self.indice

有没有办法简化以下内容:

>>> pycountry.languages.get(name='english')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pycountry/db.py", line 114, in get
    return self.indices[field][value]
KeyError: 'english'
>>> pycountry.languages.get(name='ENGLISH')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Python/2.7/site-packages/pycountry/db.py", line 114, in get
    return self.indices[field][value]
KeyError: 'ENGLISH'
>>> pycountry.languages.get(name='English')
<pycountry.db.Language object at 0x1096374d0>
>pycountry.languages.get(name='english')
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
get中的文件“/Library/Python/2.7/site packages/pycountry/db.py”,第114行
返回自索引[字段][值]
关键错误:“英语”
>>>pycountry.languages.get(name='ENGLISH')
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
get中的文件“/Library/Python/2.7/site packages/pycountry/db.py”,第114行
返回自索引[字段][值]
关键错误:“英语”
>>>pycountry.languages.get(name='English')

在上述情况下,“英语”是唯一不会导致例外的项目。

你在问什么?如果最后一个带“English”的是唯一有效的,那么你为什么不能使用它呢?也许我遗漏了什么,但为什么不直接使用
name='English.title()
?@JoelHinz--谢谢,这是一个很好的方法。我考虑的更多是SQL匹配,但您的方式似乎最适合本模块。