试图制作一个简单的密码柜式程序。我尝试在IDLE上运行它,但是每当我键入存储的键之一时,我都会不断收到NameError消息:
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
blog
NameError: name 'blog' is not defined
在Python 3.7.1上运行。这是代码:
#! python3
# pw.py - An insecure password locker program.
PASSWORDS = {'email': 'IHhafihjdf9783r043uIUGfed9',
'blog': 'dsh708fhdsosDFDfsdhasi90845',}
import sys, pyperclip
if len(sys.argv) < 2:
print('Usage: python pw.py [account] - account password')
sys.exit()
account = sys.argv[1] #Account name
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print('Password for ' + account + ' copied to account.')
else:
print('No such account found.')
从理论上讲,我应该把钥匙的价值找回来,但是那没有用。我已经尝试过搜索,但是我真的找不到问题所在。任何帮助将不胜感激。