加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

Python 口令保管箱

发布时间:2020-12-20 12:51:42 所属栏目:Python 来源:网络整理
导读:Python编程快速上手实践项目题目,欢迎指证与优化! 代码: #! python3# pw.py - An insecure password locker program.PASSWORDS = {‘email‘: ‘F7minlBDDuvMJuxESSKHFhTxFtjVB6‘,‘blog‘: ‘VmALvQyKAxiVH5G8v01if1MLZF3sdt‘,‘luggage‘: ‘12345‘}
Python编程快速上手实践项目题目,欢迎指证与优化!
代码:

#! python3
# pw.py - An insecure password locker program.
PASSWORDS = {‘email‘: ‘F7minlBDDuvMJuxESSKHFhTxFtjVB6‘,‘blog‘: ‘VmALvQyKAxiVH5G8v01if1MLZF3sdt‘,‘luggage‘: ‘12345‘}
import sys
import pyperclip
if len(sys.argv) < 2:
    print(‘Usage: python pw.py [account] - copy account password‘)
    sys.exit()

account = sys.argv[1] 
#sys.argv[]是用来获取命令行参数的,sys.argv[0]表示代码本身文件路径,所以参数从1开始
# first command line arg is the account name
print (account)

if account in PASSWORDS:
    pyperclip.copy(PASSWORDS[account])
    print(‘Password for ‘ + account + ‘ copied to clipboard.‘)
else:
    print(‘There is no account named ‘ + account)

#测试命令:打开CMD,输入py.exe + 文件名(绝对路径)+ 命令内容,
#比如:py.exe D:python_work口令保管箱.py email

执行结果:

email
Password for email copied to clipboard.
密码已到了剪切板:F7minlBDDuvMJuxESSKHFhTxFtjVB6

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读