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

后端 未结 4 822
离开以前
离开以前 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:58

    Set PYTHONIOENCODING environmental variable.

    SET PYTHONIOENCODING=cp936
    windows_prn_utf8.py > 1.txt
    

提交回复
热议问题