简体   繁体   English

从剪贴板复制文本,在剪贴板内容前后添加文本,然后将结果复制回剪贴板

[英]Copy text from clipboard, add text before and after clipboard content, then copy result back into clipboard

I'm trying to copy text from clipboard, add text before and after clipboard content, then copy result back into clipboard, but running into issues with formatting as the strings "begin" and "end" have mixtures of " and '我正在尝试从剪贴板复制文本,在剪贴板内容前后添加文本,然后将结果复制回剪贴板,但遇到格式问题,因为字符串“begin”和“end”混合了“和”

Im getting syntax errors: SyntaxError: unexpected character after line continuation character我收到语法错误:SyntaxError:行继续符后的意外字符

And not sure if im even coding this correctly...而且不确定我是否正确编码...

    import pyperclip


    clipboard_content = pyperclip.paste()
    print=(clipboard_content)

    begin = curl -XPOST \ -H "Content-type: application/json" \ -d '{"alert": "


    end = "}' \ 'https:'


    command = 'begin' + 'clipboard_content' +  'end'


    print=(command)
    pyperclip.copy("command")
import pyperclip


clipboard_content = pyperclip.paste()
print(clipboard_content)


string1 = "curl -XPOST \\\n     -H "
string2 ='"Content-type: application/json" \\\n '
string3 = "    -d"
string4single= "'"
string5 = '{"alert": '
string6double = '"'
string7 = "}"
string8 = " \\"
string9 = "https:/"
string10 ="\n"
string11="       "

command = string1 + string2 + string3 + string4single + string5 + 
string6double + string10 + string10 + clipboard_content + string10 + string10 
+ string6double + string7 + string4single + string8 + string11 + string4single 
+ string9 + string4single

print(command)
pyperclip.copy(command)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM