简体   繁体   English

Python控制台无法处理Unicode?

[英]Python console can't deal with Unicode?

(I'm using Python 3.4 for this, on Windows) (我正在Windows上使用Python 3.4)

So, I have this code I whipped out to better show my troubles: 因此,我整理了这段代码,以更好地显示我的麻烦:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import os
os.startfile('C:\\téxt.txt')

On IDLE it works as it should (it just opens that file I specified), but on Console (double-click) it keeps saying Windows can't find the file. 在IDLE上,它可以正常工作(它只是打开我指定的文件),但是在Console(双击)上,它一直说Windows找不到该文件。 Of course, if I try to open "text.txt" instead it works perfectly, as long as it exists. 当然,如果我尝试打开“ text.txt”,只要它存在,它就可以完美运行。

It's slowly driving me insane. 慢慢地让我发疯。 Someone help me, please. 请有人帮我。

您使用的编码错误,请尝试使用cp1252

# -*- coding: cp1252 -*-

您的文件名为“ C:\\téxt.txt”,请尝试使用“ C:\\ text.txt”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM