getting files from a windows network

Peter Hansen peter at engcorp.com
Tue Jun 11 05:55:11 CEST 2002


Chris Liechti wrote:
> 
> sameer_ at email.com (sameer) wrote in
> news:6bd9f01b.0206101523.7af66fc8 at posting.google.com:
> > is there a way to read files in python that are found on a windows
> > network, i.e. files that users choose to share on their computers on a
> > windows network.
> 
> do you mean by e.g.
> >>> open(r'\\computername\share\test.txt').read()
> 
> yes :-)
> 
> ( r'' is a raw string that doesn't touches backslashes unlike normal
> strings)

Or slightly simpler, just use forward slashes all the time:

>>> open('//computername/share/test.txt').read()

Except for at the DOS command line, Windows generally likes
forward slashes pretty well.

-Peter



More information about the Python-list mailing list