Opening New files
Joonas Paalasmaa
joonas at olen.to
Mon Aug 20 14:46:20 EDT 2001
Mikhael Loo wrote:
>
> What code do you used to open a new file. I've been opening existing files
> on MSW but I'm having trouble with my files and I think that I may need to
> use something besides open() if the file doesn't already exists.
If you want to write a file and it does not exist yet, Python will
create it for you.
For example
open("file", "w").write("Python rules")
creates a new file if it doesn't exist yet.
And all this works on Windoze too.
More information about the Python-list
mailing list