write whitespace/tab to a text file

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Fri Oct 19 11:25:39 EDT 2007


dirkheld wrote:

> f=open('/User/home/Documents/programming/python/test.txt','w')
>     for x in range(len(names)):
>         f.write(tags[x])
>     f.close()

Definitely consider the Python tutorial.

Also, please provide working code examples. I don't think yours will
work ;)

names = ['John','Steve','asimov','fred','jim']
f = open('/User/home/Documents/programming/python/test.txt','w')
f.write('\t'.join(names))
f.close()

A better alternative could be the csv module.

Regards,


Björn


-- 
BOFH excuse #388:

Bad user karma.




More information about the Python-list mailing list