Problem with print and output to screen

Joel Goldstick joel.goldstick at gmail.com
Tue Dec 11 17:53:37 EST 2012


When you read the file line by line the end of line character is included
in the result

try user[:-1] instead to strip the return from your printed text


On Tue, Dec 11, 2012 at 5:31 PM, Mike <miguelcoam at gmail.com> wrote:

> Hello, I am learning python and i have the next problem and i not
> understand how fix.
> The script is very simple, shows in the terminal the command but, the row
> is divided in two:
> Example:
>
>
> /opt/zimbra/bin/zmprov ga user at example.com
> |egrep
> "(zimbraPrefMailForwardingAddress:|zimbraPrefMailForwardingAddress:)"
> /opt/zimbra/bin/zmprov ga user2 at example.com
> |egrep
> "(zimbraPrefMailForwardingAddress:|zimbraPrefMailForwardingAddress:)"
>
> And the correct is:
> /opt/zimbra/bin/zmprov ga user at example.com |egrep
> "(zimbraPrefMailForwardingAddress:|zimbraPrefMailForwardingAddress:)"
>
>
> The script is:
>
> #!/usr/bin/python
> import os
>
> for user in open ("email"):
>         print '/opt/zimbra/bin/zmprov ga ' + user + '|egrep
> "(zimbraPrefMailForwardingAddress:|zimbraPrefMailForwardingAddress:)" '
>
>
>
> Thanks
> --
> http://mail.python.org/mailman/listinfo/python-list
>



-- 
Joel Goldstick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121211/a20c1696/attachment.html>


More information about the Python-list mailing list