2015年3月8日星期日

Python Tips


IOError: [Errno 22] invalid mode ('r') or filename

test_file=open('c:\\Python27\test.txt','r')
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')

没有评论:

发表评论