Reading files located on Windows-shares?
aleax at aleax.it
Mon Jan 28 13:11:28 CET 2002
"Thomas Weholt" <thomas at gatsoft.no> wrote in message
news:Z1b58.67$ti7.170870784 at news.telia.no...
> for host in hosts:
> print open('\\%s\\data\config.dat', 'r').read()
> Doesn't work. How can I work with Windows-shared folders using Python ??
Same as when using C: mind the backslashes and the substitutions.
should work better: the leading r makes this literal into a rawstring (so
backslashes are taken literally) and the % operator formats string host
into the resulting filepath. If the underlying C library supports UNC,
that's all you need. Else, you'll need the win32all extensions.
More information about the Python-list