本文为学习python编程时所记录的笔记,仅供学习交流使用。
用一个命令行参数来运行这个程序, 该参数是账号的名称。例如email, 账号的密码将拷贝到剪贴板, 然后将它粘贴到输入框。
1、将以下代码程序保存为:pw.py
#! python3
# -*- coding:utf-8 -*-
# @Time:2020-06-02
# @Author:Jenny
# pw.py - An insecure password looker program.
PASSWORD = {'email':'ZmFtaWx5ODgr',
'qq':'cmVkeWdvODgwMjE0Kw==',
'CSDN':'ZmFtaWx5ODg='}
import sys,pyperclip
if 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 name
if account in PASSWORD:
pyperclip.copy(PASSWORD[account])
print('Password for ' + account + ' copied to clipboard.')
else:
print('There is no account named ' + account)
说明:所有 Python 程序的第一行应该是#!行,它告诉计