write file to a server

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Jan 28 13:05:27 EST 2015


On 28/01/2015 14:12, Chris Angelico wrote:
> On Thu, Jan 29, 2015 at 12:38 AM, MRAB <python at mrabarnett.plus.com> wrote:
>> On 2015-01-28 13:22, luca72 wrote:
>>>
>>> Hello i'm under windows, i have to write a file from my computer to a
>>> local server like taht "\\DOCUMENTALE\my_folder\".
>>> How i have to proceed ?
>>>
>> That's a path to a folder that just happens to be on another computer on
>> your network. Treat it the same way you would for a 'local' folder,
>> eg "C:\my_folder".
>
> And if you've done that and it isn't working, one likely cause is that
> Windows uses backslashes in path names, but Python string literals
> treat backslashes specially. Use a raw string literal:
>
> path = r"\\DOCUMENTALE\my_folder\some_file_name"
> with open(path, "wb") as f:
>      ... write to file ...
>
> If you have other problems, the best thing to do is to post your code
> and the exact output it produces, especially if that's a traceback.
> Those are incredibly helpful.
>
> ChrisA
>

Windows will accept forward slashes in path names.

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list