python清空文件内容

def read_account(filename):
    with open(filename, 'r+', encoding='utf-8') as f:
        res = f.readlines()
        print(res)
        f.seek(0)
        f.truncate()

你可能感兴趣的:(python清空文件内容)