Python3中locale.setlocale的奇怪行为

时间:2018-01-09 11:57:27

标签: python locale lxml

我在两个Python程序中有相同的开头:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from lxml         import etree, html
from lxml.builder import E
import re
import sys
import locale
#locale.setlocale(locale.LC_ALL, 'es_ES.UTF-8')
locale.setlocale(locale.LC_ALL, '')

在一种情况下,一切正常,而在另一种情况下,我取消注释第一个并注释第二次调用setlocale以避免以下错误:

Traceback (most recent call last):
  File "./html2epub.py", line 11, in <module>
    locale.setlocale(locale.LC_ALL, '')
  File "/usr/lib/python3.5/locale.py", line 594, in setlocale
    return _setlocale(category, locale)
locale.Error: unsupported locale setting

当然,当LC_ALL不是&#39;

时,没有任何作用

0 个答案:

没有答案