简体   繁体   中英

How to copy a file/image to the clipboard in Linux using Python

I can't find a way to copy an image or a file to the clipboard. I tried using pyperclip but it isn't able to do that.

I found a way to do this using a shell command:

os.system(f"xclip -selection clipboard -t image/png -i {path + '/image.png'}")

It's less than ideal but it does the job.

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.

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