Last active
April 5, 2023 16:35
-
-
Save luqmaan/d8bc61e746207bb12f11 to your computer and use it in GitHub Desktop.
Write a python string to the clipboard via pbcopy (OS X)
This file contains 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
def write_to_clipboard(output): | |
import subprocess | |
process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE) | |
process.communicate(output.encode()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
'bytes' object has no attribute 'encode'