python解码和文件写入问题

时间:2014-11-30 15:21:26

标签: python file python-2.7 base64 decode

当我尝试运行这个python-2.7程序时,它没有任何错误,但问题是它不转换和写入整个文件(仅转换98959行)和原始文件包含99157行

为什么会发生这种情况?

import base64
input_file = open("answer.txt","r")
output_file = open("result.txt","w")
for eachline in input_file.readlines():
    output_file.write(base64.b64decode(eachline))

原始文件链接:https://drive.google.com/open?id=0B_566weiakkYLVBhSHJndkFMX3M&authuser=0

如果有人可以帮助我,请提前

1 个答案:

答案 0 :(得分:0)

您尚未关闭文件

output_file.close()