How to create a file on users XP desktop
goldtech
goldtech at worldpost.com
Sun Oct 7 07:58:46 EDT 2007
>
> 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.
I agree, you're right. I learn more by figuring out the code myself.
After Google briefly: In a DOS box type: SET
This was too easy - sorry.
> 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()
More information about the Python-list
mailing list