0

I always make these bash commands to adjust files where I have to either: (1) copy from stdout; or (2) create a file to copy from that I will never use again.

Is it possible to use some type of file object that actually dumps the output into the clipboard?

# In Python
with someclipboardfileobject as f:
    for i in range(10):
        print(i, file=f)

# Open up TextEdit
# Paste
0
1
2
3
4
5
6
7
8
9
O.rka
  • 29,847
  • 68
  • 194
  • 309

1 Answers1

0

There is module called pyperclip you can use it

import pyperclip

copyText = ''
with open("filename.csv") as f:
    copyText += f.read()

pyperclip.copy(copyText)
spam = pyperclip.paste()