如何在python中添加进度条?

如何在python中添加进度条?,python,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

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

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()
现在,在
打印(“检查权限”)
之间,如果回答==“是”
我想添加一个使用此字符的进度条█" 这可能吗?
感谢您的帮助!

您可以尝试以下方法:

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.
在“(是),“y”)< /C>中考虑<代码>回答.LUVER(),而不是多个测试。如果愿意,请用CudieVIEW.STACKExchange(COM)与完整脚本一起删除。