Drukuj konsolę sys.stdout

sys.stdout = open("test.txt", "w")

print("Hello World")

sys.stdout.close()
# TEST.TXT:
# Hello World
The Biton