《Python编程快速上手》6.3 项目:口令保管箱

pw.py 一个口令保管箱
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#   pw.py 一个口令保管箱
import pyperclip
import sys

PASSWORDS = {'email': 'asdfihejkagwbascarevoiwera',
'blog': 'seruniobthopaesrbnesropt',
'luggage': 'asDIUrvbyialestdbhajlsnt'}

if len(sys.argv) < 2:
print('Usage: py pw.py [account] - copy account password')
sys.exit()

account = sys.argv[1]
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print('Password for ' + account + ' copied to clipboard.')
else:
print('There is no account name called ' + account)