[Tutor] creating files on open()
Kent Johnson
kent37 at tds.net
Fri May 20 20:59:23 CEST 2005
William O'Higgins wrote:
> When I am open()-ing a file, I sort of expect that if the file doesn't
> exist that it would be created, but it doesn't, it whines about it
> instead. So, how do I create a file with Python? I've looked all over,
> but I'm obviously missing something. Thanks.
Opening a file for writing will create it:
f = open('myfile.txt', 'w')
Kent
More information about the Tutor
mailing list