Print unicode string to console OK but fails when redirect to a file. How to fix?

后端 未结 4 825
离开以前
离开以前 2020-12-21 23:00

I have Python 2.7.1 on a Simplified-Chinese version of Windows XP, and I have a program like this(windows_prn_utf8.py):

#!/usr/bin/env python
# -*- coding: u         


        
4条回答
  •  醉酒成梦
    2020-12-21 23:40

    Use codecs.open(filename,encoding) instead of open(filename) and write file with python.

提交回复
热议问题