Python打印到文件

import cPickle as p
g=p.load(file(r'D:\0_500_my\VITdata\vocabularystatistics.dat'))
f=p.load(file(r'D:\0_500_my\VITdata\infoGain.dat'))
fid=file('2.txt','a')
for key,val in g.iteritems():
    print >>fid, '%s,%s'%(key,val)
    fid.flush()
fid.close()
   

你可能感兴趣的:(python)