我对Python非常陌生,并且创建了一个小密码破解程序,它使用强力攻击,我试图让程序运行时输出进度条,这里是什么我至今:使用进度条输出
import zipfile
import sys
import time
def progress_bar(sleep_time):
for i in range(101):
time.sleep(sleep_time)
sys.stdout.write("\r[{0}] {1}%".format('#'*(i/10), i))
sys.stdout.flush()
def obtain_password(path_to_zip_file):
password = None
zip_file = zipfile.ZipFile(path_to_zip_file)
with open('wordlist.txt', 'r') as dict:
for line in dict.readlines():
possible = line.strip("\n")
try:
zip_file.extractall(pwd=possible)
password = "Password found {}".format(possible)
except:
pass
return password
所以我的问题是如何才能得到进度条输出,而obtain_password
方法运行?我是否需要稍微改变一下进度条方法?
你可以尝试有进度条和另外一个一个线程用于'gets_password'函数。 http://www.tutorialspoint.com/python/python_multithreading.htm或者你可以使'gets_password'函数稍微画一下进度条。 – grael
@grael在这一点上,对于我来说这似乎有点进步,我喜欢它,谢谢。 –