from pathlib import Path # Read file content def read_file(): test_file = "example/you_test_file.txt" contents = Path(test_file).read_text() print (contents) # print file content #debug(contents) # use can also use my custom debug method to see log in file # To write message to file for debugging def debug(message="", type="w+"): filePath = "test/debug.txt" # don't forgot to create a empty file with open(filePath, type) as f: f.write(str(message) + "\n\n") f.close()
Wednesday, 2 November 2022
Python - To read file content & write into a file
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Please post any queries and comments here.