[英]Here is a piece of code from Automate the Boring Stuff
#! python3
# pw.py - An insecure password locker program.
PASSWORDS = {'email': 'F7minlBDDuvMJuxESSKHFhTxFtjVB6',
'blog': 'VmALvQyKAxiVH5G8v01if1MLZF3sdt',
'luggage': '12345'}
import sys, pyperclip
if len(sys.argv) < 2:
print('Usage: py pw.py [account] - copy account password')
sys.exit()
account = sys.argv[1] # first command line arg is the account name
if account in PASSWORDS:
pyperclip.copy(PASSWORDS[account])
print('Password for ' + account + ' copied to clipboard.')
else:
print('There is no account named ' + account)
這是“自動化無聊的東西”中的代碼。 練習的目標是從命令提示符運行Python文件。 我已經創建了批處理文件並將其添加到PATH中。
我在“運行”對話框中輸入了“密碼(電子郵件)”,但它始終顯示“沒有帳戶名為電子郵件”
可能是我以錯誤的格式輸入了它或者是什么?
我建議你在電子郵件中丟失那些()
,如果這不起作用,那么嘗試運行cmd並導航到你的pw.py
文件夾。 進入該文件夾后,鍵入:
pw.py email
這應該采用您的代碼account = sys.argv[1]
聲明的第一個參數account = sys.argv[1]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.