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.
+ 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
0
the code is work.but im not understand that.thnx anyway