Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19842 > unrolled thread

Re: Help writelines

Started byMarkus Rother <markus.rother@web.de>
First post2012-02-03 21:41 +0100
Last post2012-02-03 21:41 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Help writelines Markus Rother <markus.rother@web.de> - 2012-02-03 21:41 +0100

#19842 — Re: Help writelines

FromMarkus Rother <markus.rother@web.de>
Date2012-02-03 21:41 +0100
SubjectRe: Help writelines
Message-ID<mailman.5418.1328301725.27778.python-list@python.org>
Hi,

You have to iterate.
Either with

for u in users:
     fob.write( u + '\n' )

or with a lambda function.

always a good call: http://python.org/

greets,
M.

On 02/03/2012 09:27 PM, Anatoli Hristov wrote:
> Hi everyone,
>
> I`m totaly new in python and trying to figure out - how to write a 
> list to a file with a newline at the end of each object.
> I tried alot of combinations :) like:
> users = ['toli','didi']
> fob=open('c:/Python27/Toli/username','w')
> fob.writelines(users) + '%s\N'
> fob.close()
>  or fob.writelines('\N' % users)
> or fob.writelines('%s\N' % users)
> but nothing of dose works...
>
> Could you help me find out the right syntaxes?
>
> Thanks
>
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web