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

后端 未结 23 3168
温柔的废话
温柔的废话 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:24

    You can use winclip32 module! install:

    pip install winclip32
    

    to copy:

    import winclip32
    winclip32.set_clipboard_data(winclip32.UNICODE_STD_TEXT, "some text")
    

    to get:

    import winclip32
    print(winclip32.get_clipboard_data(winclip32.UNICODE_STD_TEXT))
    

    for more informations: https://pypi.org/project/winclip32/

提交回复
热议问题