[Tutor] Acessing files in Windows 2000
jfouhy at paradise.net.nz
jfouhy at paradise.net.nz
Tue Mar 8 23:48:12 CET 2005
Quoting Dave S <pythontut at pusspaws.net>:
> I need to access 'memo.txt' in 'my documents' on windows & am
> struggling.
> I have tried just about every combination of \ and / and \\ and // but
> to no avail.
> I need something like ...
>
> C:\My Documents\memo.txt
>
> Can anyone advise me ?
I've never had any trouble accessing files in Win2k with python.
The following would all work for me:
f1 = file('c:\\My Docments\\memo.txt')
f2 = file('c:/My Documents/memo.txt')
f3 = file(os.path.normpath('c:/My Documents/memo.txt')) # os.path.normpath
normalizes a path; it also converts / to \\ on Windows platforms
Is your path correct? The "My Documents" folder doesn't normally live in the
root in Win2k; it is more likely to be found somewhere like C:\Documents and
Settings\Username\My Documents. Or, in an office environment, it might be on a
network share --- eg, H:\.
HTH.
--
John.
More information about the Tutor
mailing list