Writing dictionary output to a file
Peter Otten
__peter__ at web.de
Sat Mar 6 05:13:20 EST 2004
dont bother wrote:
> I have this dictionary output as per the format I
> desired :
> index : value
> However, I want to write this to a file, instead of
> just printing out to the std output.
> for i, v in enumerate(dct):
> print i,":",v
Here's how to print to a file instead of stdout:
dest = file("tmp.txt", "w")
for i, v in enumerate(dct):
print >> dest, i, ":", v
dest.close()
Peter
More information about the Python-list
mailing list