How to creat a file?

Laurent RAHUEL laurent.rahuel at net-ng.com
Fri Dec 2 07:59:46 EST 2005


sandorf wrote:

> I'm new to python. Have a simple question.
> 
> "open" function can only open an existing file and raise a IOerror when
> the given file does not exist. How can I creat a new file then?

fic = open('test.txt', 'w')
fic.write('Hello world')
fic.close()





More information about the Python-list mailing list