初学python,尝试着写一写,仅供参考,欢迎指正!
8.9.1 扩展多重剪贴板
扩展本章中的多重剪贴板程序,增加一个delete <keyword>命令行参数,它将从shelf 中删除一个关键字。然后添加一个delete 命令行参数,它将删除所有关键字。
#! python
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 13 16:20:42 2018
@author: zhq
"""
#mcb.pyw - saves and loads pieces of text to the clipboard
#usage: py.exe mcb.pyw save <keyword> - saves clipboard to keyword
# py.exe mcb.pyw <keyword> - loads keyword to clipboard
# py.exe mcb.pyw list - loads all keywords to clipboard
# py.exe mcb.pyw delete <keyword> - deletes the keyword
# py.exe mcb.pyw delete - delete all keywords
import shelve, pyperclip, sys
mcbShelf=shelve.open('mcb')
#save clipboard content
if len(sys.argv)==3 and sys.argv[1].lower()=='