Python num2words法语翻译中的错误

时间:2016-07-12 18:36:40

标签: python

我正在使用Python的num2words库来将数字翻译成法语单词。 但是我遇到了以下情况的编码问题:

num2words((5.05),lang='fr')

输出:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/num2words/__init__.py", line 50, in num2words
return converter.to_cardinal(number)
File "/usr/local/lib/python2.7/dist-packages/num2words/base.py", line 93, in to_cardinal
return self.to_cardinal_float(value)
File "/usr/local/lib/python2.7/dist-packages/num2words/base.py", line 127, in to_cardinal_float
out.append(str(self.to_cardinal(curr)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 1: ordinal not in range(128)

它似乎来自“zéro”字符串。但是当没有点时我没有问题:

num2words((0),lang='fr')

输出:

u'z\xe9ro'

你能帮忙吗?

谢谢!

0 个答案:

没有答案