file = open('myfile.txt', 'w') file.write('Hello file world!\n') # Or: open().write() file.close() # close not always needed