which is the right file path format in python3.4 ?

sir elearn2014 at gmail.com
Sun Dec 14 04:05:29 EST 2014


My system is :win7+python3.4  .

I want to write a new file "named names.txt"  in disk f:

  >>> ff=open(r"F:\names.txt","w")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'F:\\names.txt'
 >>> ff=open(r"F:/names.txt","w")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'F:/names.txt'
 >>> ff=open(r"F://names.txt","w")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'F://names.txt'
 >>> ff=open(r"f://names.txt","w")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'f://names.txt'
 >>> ff=open(r"f:/names.txt","w")
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument: 'f:/names.txt'

which is the right  file path format in python3.4 ?



More information about the Python-list mailing list