Python 2
私は次が好きです:
print 'Downloading File FooFile.txt [%d%%]\r'%i,
デモ:
import time
for i in range(100):
time.sleep(0.1)
print 'Downloading File FooFile.txt [%d%%]\r'%i,
Python 3
print('Downloading File FooFile.txt [%d%%]\r'%i, end="")
デモ:
import time
for i in range(100):
time.sleep(0.1)
print('Downloading File FooFile.txt [%d%%]\r'%i, end="")
Python3を搭載したPyCharmデバッガコンソール
# On PyCharm Debugger console, \r needs to come before the text.
# Otherwise, the text may not appear at all, or appear inconsistently.
# tested on PyCharm 2019.3, Python 3.6
import time
print('Start.')
for i in range(100):
time.sleep(0.02)
print('\rDownloading File FooFile.txt [%d%%]'%i, end="")
print('\nDone.')