How do I copy a string to the clipboard on Windows using Python?

后端 未结 23 3167
温柔的废话
温柔的废话 2020-11-22 03:13

I\'m trying to make a basic Windows application that builds a string out of user input and then adds it to the clipboard. How do I copy a string to the clipboard using Pytho

23条回答
  •  独厮守ぢ
    2020-11-22 03:34

    Not all of the answers worked for my various python configurations so this solution only uses the subprocess module. However, copy_keyword has to be pbcopy for Mac or clip for Windows:

    import subprocess
    subprocess.run('copy_keyword', universal_newlines=True, input='New Clipboard Value 

提交回复
热议问题