Created
March 23, 2020 22:26
-
-
Save duncangh/0ba31b88ac8183f059538ab38ad1d225 to your computer and use it in GitHub Desktop.
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
import subprocess | |
def write_to_clipboard(output): | |
process = subprocess.Popen( | |
'pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE) | |
process.communicate(output.encode('utf-8')) | |
#How to read a Unicode string from the Mac clipboard: | |
import subprocess | |
def read_from_clipboard(): | |
return subprocess.check_output( | |
'pbpaste', env={'LANG': 'en_US.UTF-8'}).decode('utf-8') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment