Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #84757

Re: write file to a server

References <6b5943a2-ab9d-4949-bfbe-7671740bb9fb@googlegroups.com> <54C8E653.3070908@mrabarnett.plus.com>
Date 2015-01-29 01:12 +1100
Subject Re: write file to a server
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.18219.1422454345.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Thu, Jan 29, 2015 at 12:38 AM, MRAB <python@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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

write file to a server luca72 <lucaberto@libero.it> - 2015-01-28 05:22 -0800
  Re: write file to a server MRAB <python@mrabarnett.plus.com> - 2015-01-28 13:38 +0000
  Re: write file to a server Chris Angelico <rosuav@gmail.com> - 2015-01-29 01:12 +1100
  Re: write file to a server Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-28 18:05 +0000
  Re: write file to a server Chris Angelico <rosuav@gmail.com> - 2015-01-29 08:38 +1100
  Re: write file to a server luca72 <lucaberto@libero.it> - 2015-01-28 23:44 -0800

csiph-web