How to create a file on users XP desktop
drobinow at gmail.com
drobinow at gmail.com
Sun Oct 7 00:34:40 EDT 2007
More information about the Python-list mailing list
Sun Oct 7 00:34:40 EDT 2007
- Previous message (by thread): How to create a file on users XP desktop
- Next message (by thread): How to create a file on users XP desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Oct 6, 11:31 pm, goldtech <goldt... at worldpost.com> wrote: > Can anyone link me or explain the following: > > I open a file in a python script. I want the new file's location to be > on the user's desktop in a Windows XP environment. fileHandle = open > (....., 'w' ) what I guess I'm looking for is an environmental > variable that will usually be correct on most XP desktops and will > work in the open statement. Or is there another way? This is really a Windows question, not a Python question. You should have been able to figure it out yourself by examining existing environment variables. Something like the code below should work for you if the standard environment variables haven't been hosed. ---------- import os Filename = os.getenv("HOMEDRIVE") + os.getenv("HOMEPATH") + "\\Desktop \MyNewFile" f = file(Filename, "w") f.write("Here's a file on the desktop\n") f.close()
- Previous message (by thread): How to create a file on users XP desktop
- Next message (by thread): How to create a file on users XP desktop
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list