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

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

    You can use the excellent pandas, which has a built in clipboard support, but you need to pass through a DataFrame.

    import pandas as pd
    df=pd.DataFrame(['Text to copy'])
    df.to_clipboard(index=False,header=False)
    

提交回复
热议问题