save console output to file python code example
Example: python export console output to file
sys.stdout = open("test.txt", "w")
print("Hello World")
sys.stdout.close()
# TEST.TXT:
# Hello World
sys.stdout = open("test.txt", "w")
print("Hello World")
sys.stdout.close()
# TEST.TXT:
# Hello World