python export console output to file

41

python export console output to file -

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

print("Hello World")

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

Comments

Submit
0 Comments