📅  最后修改于: 2022-03-11 14:45:29.658000             🧑  作者: Mango
with open(fname, 'r+') as fd:
lines = fd.readlines()
fd.seek(0)
fd.writelines(line for line in lines if line.strip())
fd.truncate()