Skip to content

Instantly share code, notes, and snippets.

@jwenjian
Last active June 24, 2019 05:26
Show Gist options
  • Save jwenjian/8e672c62eeddb4c56d3014b0f3cfd0ec to your computer and use it in GitHub Desktop.
Save jwenjian/8e672c62eeddb4c56d3014b0f3cfd0ec to your computer and use it in GitHub Desktop.
Copy a string to clipboard using python
import pyperclip
def copy_to_clipboard(command: str):
pyperclip.copy(str(command))
if __name__ == '__main__':
copy_to_clipboard("Hello, world!")
copied_str = pyperclip.paste()
print(copied_str) # Hello, world!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment