Windows 下 Pycharm 的正确编码设置?,windowspycharm,在 Pycharm 中运


在 Pycharm 中运行以下程序:

#! /usr/bin/python# -*- coding: utf8 -*-print "running test..."print u"测试"w = raw_input(u"输入:".encode("mbcs"))print u"%s" % (w)a = u"中文"print u"Show As: %s" % (a)

在控制台中输出始终存在乱码:

running test...�������룺aaaaaaShow As: ����

但是,该程序在 Windows 的命令行中运行正常:

running test...测试输入:aaaaaaShow As: 中文

这里 PyCharm 的 “IDE Encoding” 和 “Project Encoding” 无论设置为 UTF-8 还是 GBK 对乱码均没有显著效果。但是,如果直接

print "测试"

却可以正常输出。

请教一下大家,这里该怎么设置才能保证各平台下中文显示均正常?(注:chcp 为 936)

编橙之家文章,

评论关闭