IOError:[Errno 22]用于带有中文字符的文件名

时间:2013-07-03 14:08:47

标签: python python-2.7

我在尝试打开()时读取Python项目中的错误.read()一个名称包含中文字符的文件。这是我得到的错误:

IOError: [Errno 22] invalid mode ('rb') or filename: 'C:\\Users\\Bob\\Document
s\\Desktop\\Test2\\projects\\cplusplus-practices-2011\\ cplusplus-practices-2011
\\??????.cpp'

其中??????。cpp是由中文字符组成的文件名。

以下是发生错误的行:

source_file = open(dir_file,'rb').read()

为了让Python能够打开或读取文件名中包含中文字符的文件,我需要做些什么?

0 个答案:

没有答案
相关问题