0
只是一個小項目,我正在努力提高我的知識水平。 對於程序總是返回失敗的原因感到好奇,即使正確輸入了驗證碼也是如此。我認爲這與結果沒有存儲在內存中有關係嗎?驗證碼程序總是返回失敗
import string
import random
def captcha_gen(size=7, chars=string.ascii_letters + string.digits):
return ''.join(random.SystemRandom().choice(chars) for _ in range(size))
results = print(captcha_gen())
user_input = input("Please enter the captcha code as you see it: ")
if user_input == results:
print("success")
elif user_input != results:
print("failure")
else:
print("error")
謝謝!