一 快速对剪切板中的文本内容每行添加标注,如‘*’
1 #!pthon3 2 #快速标记文本 3 #对复制到剪切板上的内容添加一些简单的注释 4 5 #导入剪切板模块 6 import pyperclip 7 8 #把剪切板上的内容复制到文本保存 9 text = pyperclip.paste() 10 11 #对文本的内容增加注释 12 lines = text.split('\n') #按照换行拆分 13 for i in range(len(lines)): #每个字符串前面加* 14 lines[i] = '* '+lines[i] 15 text = '\n'.join(lines) #对文本进行重新拼接 16 17 #把文本内容不知道到剪切板 18 pyperclip.copy(text)
二 口令保管箱
利用字典存储复杂的密集,可以通过口令快速复制到剪切板上,不用实现密码的输入
1 #!python3 2 #pw.py--An insecure password locker program. 3 PASSWORDS = {'mogi':"weishenmexianzaihuiqilaidoushileine", 4 'qilv':"cengjingkeyidedaoxianzaiqueshiqu"} 5 6 import sys,pyperclip 7 if len(sys.argv) < 2: 8 print("Usage:py pw.py[account] - copy account password") 9 sys.exit() 10 11 account = sys.argv[1] #first command line arg is the account name 12 13 if account in PASSWORDS: 14 pyperclip.copy(PASSWORDS[account]) 15 print("password for " + account + ' copied to clipboard!') 16 else : 17 print('There is no account named '+ account)