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

时间:2015-06-02 18:32:02

标签: 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.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>

在上面,&#39;英语&#39;是唯一没有导致异常的项目。

0 个答案:

没有答案