I am learning python and would like verification on a hunch I have about CL args and Python's clipboard. When passing CL args to a script does that arg automatically get added to the clipboard. The code that makes me ask this question is pasted below:
import shelve, pyperclip, sys
#mcb.py - saves and loasd pieces of text to the clipboard
#usage: py.exe mcb.py save <keyword> - saves clipboard to keyword
# py.exe mcb.py list - loads all keywords to clipboard
# py.exe mcb.py <keyword> -loads keyword to clipboard
mcbShelf = shelve.open('mcb')
if len(sys.argv)==3 and sys.argv[1].lower()=='save':
mcbShelf[sys.argv[2]] = pyperclip.paste()
elif len(sys.argv) == 2:
if sys.argv[1].lower =='list':
pyperclip.copy(str(list(mcbShelf.keys())))
elif sys.argv[1] in mcbShelf:
pyperclip.copy(mcbShelf[sys.argv[1]])
mcbShelf.close()
程序参数不会复制到“剪贴板”,但是可以通过sys.argv
访问(上面的代码似乎是使用pyperclip将代码复制到剪贴板的)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.