import base64 filea = open(r'c:\1.txt','r') lines = filea.readlines()writefile=open(r'c:\2.txt','w')for i in lines: word = i.strip() b = base64.decodestring(word) print b writefile.write(b) writefile.write('\n')writefile.close()filea.close()