MENU
CLOSE
NOTES
CONTACT
Source: 📖 Python Cookbook ch5.2 p144
You can print to a file instead of the console by specifying a file argument for the print function.
file
print
with open('printfile.txt', 'w') as f: print("Hello, World!", file=f)