why writing list to file puts each item from list on seperate line?
limodou
limodou at gmail.com
Fri Dec 30 23:30:47 EST 2005
More information about the Python-list mailing list
Fri Dec 30 23:30:47 EST 2005
- Previous message (by thread): why writing list to file puts each item from list on seperate line?
- Next message (by thread): why writing list to file puts each item from list on seperate line?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
30 Dec 2005 20:22:52 -0800, homepricemaps at gmail.com <homepricemaps at gmail.com>: > if i use the code below to write a list to a file > > list = (food, price, store) > data.append(list) > f = open(r"test.txt", 'a') > f.write ( os.linesep.join( list ) ) > > > it outputs to a file like this > > apple > .49 > star market > > and i want it to do > > apple, .49. star market > > any ideas > my box is windows xp, so : >>> print repr(os.linesep) '\r\n' If you want to seperate them with space, you should: f.write ( ''.join( list ) ) and list = (food, price, store) the list is not called "list", but "tuple", a real list should be aList = [food, price, store] -- I like python! My Blog: http://www.donews.net/limodou NewEdit Maillist: http://groups.google.com/group/NewEdit
- Previous message (by thread): why writing list to file puts each item from list on seperate line?
- Next message (by thread): why writing list to file puts each item from list on seperate line?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list