您好,登錄后才能下訂單哦!
Python編程快速上手實(shí)踐項(xiàng)目題目,歡迎指證與優(yōu)化!
代碼:
#! 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[]是用來獲取命令行參數(shù)的,sys.argv[0]表示代碼本身文件路徑,所以參數(shù)從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 + 文件名(絕對路徑)+ 命令內(nèi)容,
#比如:py.exe D:\python_work\口令保管箱.py email
執(zhí)行結(jié)果:
email
Password for email copied to clipboard.
密碼已到了剪切板:F7minlBDDuvMJuxESSKHFhTxFtjVB6
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。