How to PythonRead
File contentAfter modifying
Write
Return to the original file
漂亮男人2017-06-28 09:27:30
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)