+ 1

Python replace printed output

print("wow you good") then its print "wow you good" how to replace wow with okay in output? im using linux with python 3.5

23rd Jul 2017, 3:50 AM
Kevin AS
Kevin AS - avatar
3 Respuestas
+ 1
Sorry. I'm used to using modules. How about an easier way :) num = 0 for i in range(10) print(num, end='\r') try that. what does the work is the (end="\r") in the print function, which is a carriage return as well. There is no need to import anything with this method. ^.^ Btw a carriage return is basically telling python to reread the line (unless someone can explain it better ^^). It works the same as a real life old style typewriter.
23rd Jul 2017, 5:57 AM
Sapphire
+ 1
Try using a carriage return, this is a crude example, but it's how you do it: import sys as sys num = 0 for i in range(10) sys.stdout.write ("Current number: %d%% \r" % (num)) sys.stdout.flush() num += 1 Here's more information on what each method does. https://docs.python.org/2/library/sys.html
23rd Jul 2017, 5:36 AM
Sapphire
0
the code is work.but im not understand that.thnx anyway
23rd Jul 2017, 5:37 AM
Kevin AS
Kevin AS - avatar