which is the right file path format in python3.4 ?
Irmen de Jong
irmen.NOSPAM at xs4all.nl
Sun Dec 14 04:52:27 EST 2014
On 14-12-2014 10:05, sir wrote:
> 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 ?
They all should work. (They do on my machine when subtituting F with a drive letter that
exists here. Win 7, Python 3.4.2).
It's something else on your end that is causing the error. Is drive F: full? Do you have
the correct permissions? Is it a network share that has certain restrictions?
What exact python is is that you are running?
Irmen
More information about the Python-list
mailing list