昨日の続き
今読んでる章
Chapter 6 – Manipulating Strings
覚えた構文
code
章の最後にあるプログラムを作ろうコーナー
コード内に記載のパスワードをクリップボードにコピーする
pyperclipというモジュールを使ってクリップボードに保管するらしいが、pyperclipのエラーが出て今く動かない...
もう少し調べる。
#! python3 # pw.py - An insecure password locker program. PASSWORDS = {'email': 'xxxxxxxx', 'blog': 'xxxxxxx'} 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 PASSWORDS: pyperclip.copy(PASSWORDS[account]) print('Password for ' + account + ' copied to clipboard.') else: print('There is no account named ' + account)