How to PythonRead File contentAfter modifying WriteReturn to the original file
Read
After modifying
Write
Reference article: Issues related to Python file operations
Modify the file content and write back the original file
with open(filename) as f: file_str = f.read() # do stuff with file_str with open(filename, 'w') as f: f.write(file_str)
Reference article: Issues related to Python file operations
Modify the file content and write back the original file