IOError: [Errno 22] invalid mode ('r') or filename: 'E:\x07nu\meta.csv'

IOError: [Errno 22] invalid mode ('r') or filename: 'E:\x07nu\meta.csv'

IOError:[Errno 22] 无效模式('r')或文件名:'E:\x07nu\meta.csv'

f = open("E:\anu\meta.csv","r")


for line in file:

        x = line.split(",")

        print(x[0])

尝试以下不解释路径转义序列的方法(如 \a)

f = open(r"E:\anu\meta.csv","r")

\a 正在制造问题。 \a 和 \t 等字符会造成此类问题。

改为使用原始字符串:

test_file=open(r'E:\anu\meta.csv','r')

或双斜线:

test_file=open('E:\anu\meta.csv','r')

或改用正斜杠:

test_file=open('E:/anu/meta.csv','r')

如果使用Python 2.7,以二进制模式打开'rb'.

尝试使用以下任一方法:

f = open(r'E:\anu\meta.csv','rb') as f

f = open(r'E:\anu\meta.csv','rb') as f