When I'm running a script and I'm not sure what's going on, I use a lot of Print statements, but this is pretty ugly, so I'll implement a progress bar that uses "#".
Ruby
test.rb
(0..10).each do |i|
sleep(1)
print "\r" + "%3d" % (100.0 * i.to_f / 10.0) + "% " + "#" * i
end
puts "\nEND"
Python
test.py
import time
for i in range(11):
time.sleep(1)
print("\r{0:3d}%".format(int(100.0 * i / 10)), "#" * i , end='')
print('\nEND')
Execute the command.
python
$ ruby test.rb
100% ##########
END
$ python test.py
100% ##########
END
I don't know from the result alone, but the number of "#" has increased over time (^ _ ^;) It might be convenient ...
By the way, you can also use it with Jupyter notebook. However, in the case of Python, there is a dedicated library, so you may not use it (sweat)
Please check the following article for how to use it. http://qiita.com/mix_dvd/items/e613c2714c7ea0e81be9
Recommended Posts