[英]Why doesn't my funtion print anything?
我正在尝试在Python中创建一个功能,该功能根据文件中的所有单词及其相应的加密(此功能来自crypto_password函数)来创建字典。 该功能不会产生错误,但是也不会输出密码字典。 我要去哪里错了?
输入现在看起来像这样:
import hashlib
def encrypt_password( passwd ):
"""Encrypt a plaintext password (a string). It returns the result.
This encryption is one-way only, meaning it is not easy (impossible) to decrypt
the encrypted password to find out the original plaintext password again."""
return hashlib.sha256( passwd.encode() ).hexdigest()
keys = open('words.txt').read().splitlines()
values = []
for i in keys:
e = encrypt_password(i)
values.append(e)
password = dict(zip(keys, values))
print(password)
提前致谢!
您有变量Passwords(密码),不同拼写的密码。 密码指的是什么?
这似乎是一个错字:密码字典首先被称为“密码”,其次被称为“密码”。 可能您的意思是:
passwords = dict(zip(keys, values))
print(passwords)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.