Closed youyu closed 17 hours ago
同问,在windows下,我用 input_writeln 输出UTF8的中文字符串,写入文件的时候会自动换成GBK的,没能找到相关设置。
IO
的构造方式有一种是:
IO(open('data.in', 'w+'), open('data.out', 'w+'))
尝试 open 时改成:
open('data.in', 'w+', encoding='utf-8')
encoding
指定了编码格式。
我只测试了生成输入,测试代码如下:
from cyaron.io import *
name = "test.in"
file = open("test.in", "w+", encoding="utf-8")
# test = IO(name, disable_output=True)
test = IO(file, disable_output=True)
test.input_writeln("你好")
可以生成 utf-8 格式的文件。
修了 根据pylint的指示 全部默认采用utf-8格式io
有些题目,输出中含有中文,生成文件,上传到OJ时,会无法显示