469,945 Members | 2,294 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,945 developers. It's quick & easy.

Re: python lists and newline character

Gary Herron wrote:
Support Desk wrote:
Hello all,

I am using os.popen to get a list returned of vpopmail
users, something like this

x = os.popen('/home/vpopmail/bin/vuserinfo -n -D

x returns a list, of usernames, and I am trying to append the
usernames with the domain like so

for line in x:

print line + ‘@’ + domain

but instead of getting

us**@domain.com <mailto:us**@domain.com>

im getting a newline character like:







Is there some way I can get this list without the newline characters
being added. or somehow remove the newline characters. Any help would
be appreciated.

The problem has nothing to do with lists. The readlines() function
returns each line *with* its newline. To strip it off, use line.strip()

Gary Herron


Also os.popen is deprecated. You should probably learn subprocess.

Gary M. Josack
Jul 29 '08 #1
0 1159

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

54 posts views Thread by Brandon J. Van Every | last post: by
699 posts views Thread by mike420 | last post: by
20 posts views Thread by Lucas Raab | last post: by
1 post views Thread by JackPhil | last post: by
reply views Thread by Gary Herron | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.