Last active
June 20, 2018 08:37
-
-
Save RecNes/a803a9d3705c3017e9a09d9948a01881 to your computer and use it in GitHub Desktop.
Display percentage of process to on one line of stdout in python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object_list_length = len(ObjectList) | |
for i, object in enumerate(ObjectList): | |
percentage = int(((i + 1) * 100 / object_list_length)) | |
percent_str = "" | |
for k in range(0, int(percentage / 5)): | |
percent_str += ":" | |
sys.stdout.write("\r%s -- %s | %s %% %s " % (str(i + 1), | |
str(object_list_length), | |
str(percentage), | |
percent_str) | |
) | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment