我正在从CSV文件导入数据,输入210行后,它返回此错误。我从 Django shell (manage.py shell 中执行此操作)
ERROR - failed to write data to stream: <open file '<stdout>', mode 'w' at 0x104c8f150>
这是非 UTF-8 的 IPython 编码的问题。 export PYTHONIOENCODING=UTF-8
会解决它。
这成功了。
# sys.setdefaultencoding() does not exist, here!
import sys
reload(sys) # Reload does the trick!
sys.setdefaultencoding('UTF-8')