IOError:[Errno 22] invalid mode('r')or filename:'c:\\Python27\test.txt' [英] IOError: [Errno 22] invalid mode ('r') or filename: 'c:\\Python27\test.txt'

查看:727
本文介绍了IOError:[Errno 22] invalid mode('r')or filename:'c:\\Python27\test.txt'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是什么错误:

  test_file = open('c:\\Python27\test。 txt','r')


解决方案

\ t 是制表符。使用原始字符串:

  test_file = open(r'c:\Python27\test.txt','r ')

或双斜杠:

  test_file = open('c:\\Python27\\test.txt','r')

或使用正斜杠代替:

$ p $ test_file = open('c :/Python27/test.txt','r')


What is wrong with the following:

test_file=open('c:\\Python27\test.txt','r')

解决方案

\t is a tab character. Use a raw string instead:

test_file=open(r'c:\Python27\test.txt','r')

or double the slashes:

test_file=open('c:\\Python27\\test.txt','r')

or use forward slashes instead:

test_file=open('c:/Python27/test.txt','r')

这篇关于IOError:[Errno 22] invalid mode('r')or filename:'c:\\Python27\test.txt'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆