【发布时间】:2019-01-02 23:23:57
【问题描述】:
我正在使用 Python2 编写,并导入了 __future__ 库。
当我想按如下方式记录一个 unicode 字符串时,
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import logging
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.info("╔")
我收到了这个错误。
Traceback (most recent call last):
File "/usr/local/gcc-5-glibc-2.23/lib/python2.7/logging/__init__.py", line 876, in emit
stream.write(fs % msg.encode("UTF-8"))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 231: ordinal not in range(128)
【问题讨论】: