[Tutor] Acessing files in Windows 2000
R. Alan Monroe
amonroe at columbus.rr.com
Wed Mar 9 03:15:10 CET 2005
> I have a script that converts data relating to my work.
> It works great on my Linux system but some of my colleagues run windows.
> I am attempting to convert the file paths to windows but am having no luck.
> 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
You'll have to come up with some windows-specific trick to find out
the current user, because "my documents" is actually in
c:\documents and settings\currentusername\my documents\
Try getting it from the HOMEPATH environment variable.
import os
print os.environ['HOMEPATH']
Alan
More information about the Tutor
mailing list