简体   繁体   中英

Copy list to clipboard in Python

I have a list named final and I want to copy it to the clipboard. I want every element in the list to be a line. (Ex: ["foo", "bar"] into 2 lines foo and bar ) I've tried pyperclip, but it doesn't support lists.

pyperclip.copy("\\n".join(final))

You could use pyautogui

import pyautogui

test = ['string1', 'string2', 'string3']

for word in test:
    pyautogui.typewrite(word + '\n')

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