How to I print without newline ?
Chris Herborth
chrish at cryptocard.com
Fri May 28 10:24:13 EDT 2004
fowlertrainer at anonym.hu wrote:
> I want to print, but without newline. I want to create a progress for
> ftp, but the print is drop a newline for every percent.
> I want like this:
>
> 0% 25% 50% 75% 100%
>
> But this happening:
> 0%
> 25%
> 50%
> 75%
> 100%
>
> How to I prevent the newlines ?
One option:
s = [ 0, 25, 50, 75, 100 ]
for p in s:
percent = "%d%%" % ( p, )
print percent,
Another option:
from sys import stdout
s = [ 0, 25, 50, 75, 100 ]
for p in s:
stdout.write( "%d%% " % ( p, ) )
stdout.write( "\n" )
--
Chris Herborth chrish at cryptocard.com
Documentation Overlord, CRYPTOCard Corp. http://www.cryptocard.com/
Never send a monster to do the work of an evil scientist.
More information about the Python-list
mailing list