📜  截断在python代码示例中添加奇怪的符号

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

代码示例1
To solve the above error Try This:
  with open('file.txt','r+') as f:
    # Try to seek the position to 0
    f.seek(0)
    f.truncate(0)
for me it solved the problem

OR
import fileinput

for line in fileinput.input('file.txt', inplace=1):
  pass