📜  如何使用截断的python读取然后覆盖文件 - Python代码示例

📅  最后修改于: 2022-03-11 14:45:52.451000             🧑  作者: Mango

代码示例1
pythonCopywith open('myFolder/myfile.txt','r+') as myfile:
    data = myfile.read()
    myfile.seek(0)
    myfile.write('newData')
    myfile.truncate()