所以我对python很陌生,几天前开始学习......我遇到了一个练习项目,我们将在其中创建一个存储帐户及其各自密码的密码柜。#! python3# pw.py - An insecure password locker program.PASSWORDS = {'email': 'F7minlBDDuvMJuxESSKHFhTxFtjVB6', 'blog': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt', 'luggage': '12345'}import sysif len(sys.argv) < 2: print('Usage: python pw.py [account] - copy account password') sys.exit()account = sys.argv[1] # first command line arg is the account nameif account in PASSWORDS: pyperclip.copy(PASSWORDS[account]) print('Password for ' + account + ' copied to clipboard.')else: print('There is no account named ' + account)这就是代码。因此,PASSWORDS如果之前不存在该帐户,我想了一种用新信息更新字典的方法。所以我在else语句中添加了这几行代码 print('Input the password for the said account to update the info.') PASSWORDS[account] = input() print('Info updated!')我现在面临的问题是添加到字典中的值在程序完成后不会持久化。
添加回答
举报
0/150
提交
取消