account = sys.argv[1] if account in passwords.keys(): # if account in passwords: pyperclip.copy(passwords[account]) print(f'{account}的密码已复制到剪贴板。') else: print('你输入的账号不存在')
Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Although practicality beats purity. Errors should never pass silently. Unless explicitly silenced. In the face of ambiguity, refuse the temptation to guess. There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. Now is better than never. Although never is often better than *right* now. If the implementation is hard to explain, it's a bad idea. If the implementation is easy to explain, it may be a good idea. Namespaces are one honking great idea -- let's domore of those!
为python之禅添加无序列表(在每行开头加*)
1 2 3 4 5 6 7 8
import pyperclip
text = pyperclip.paste() lines = text.split('\n') for i inrange(len(lines)): lines[i] = '* ' + lines[i] text = '\n'.join(lines) pyperclip.copy(text)