如何在python中添加进度条?

2024-09-28 05:19:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我被要求做一个“特权检查器”,到目前为止进展得很顺利。这是我的密码:

def Privilige():
     print("Welcome to Privilege checker V0.011")
     print("Would you like to check your privileges?")
     answer = input("Type 'Yes' or 'No' and hit enter ('Y', 'y', 'N', or 'n' are also valid choices).")
     print("Checking priviliges.")
     if answer == "yes" or answer == "Yes" or answer == "Y" or answer == 'y':
         print("Privileges: Checked")
     elif answer == "no" or answer == "No" or answer == 'N' or answer == 'n':
         print("Privileges: Unchecked.")
     else:
          print("Please enter a valid option.")
Privilige()

现在,在print("Checking privileges.")if answer == "yes"之间,我想添加一个使用这个字符的进度条█" 这可能吗? 感谢您的帮助,谢谢


Tags: ortonoanswerifyes特权print
1条回答
网友
1楼 · 发布于 2024-09-28 05:19:12

你可以这样做:

from time import sleep

for i in range(60):  # Change this number to make it longer or shorter.
    print('█', end='')
    sleep(0.1)  # Change this number to make it faster or slower.

相关问题 更多 >

    热门问题