Created
June 30, 2016 16:52
-
-
Save coreyhermanson/99c397e280441613626a5a1578d691e4 to your computer and use it in GitHub Desktop.
Takes a list of strings and copies them to the Clipboard, ready to paste. Useful function if you need to copy a list of results into Excel or Notepad++. Uses Python and pyperclip module.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pyperclip | |
example_list = ["Line 1", "Line 2", "Line 3", "forever and ever"] | |
def list_to_clipboard(output_list): | |
""" Check if len(list) > 0, then copy to clipboard """ | |
if len(output_list) > 0: | |
pyperclip.copy('\n'.join(output_list)) | |
print('Copied to clipboard: ') | |
else: | |
print("There was nothing on the clipboard") | |
print(example_list) | |
list_to_clipboard(example_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This command doesn't work for a python virtual machine symced with Android system