Pyperclip module in Python
Pyperclip is a cross-platform Python module for copy and paste clipboard functions. It works with both Python 2 and 3. This module was created to enable cross-platform copy-pasting in Python which was earlier absent. The pyperclip
module has copy()
and paste()
functions that can send text to and receive text from your computer’s clipboard. Sending the output of your program to the clipboard will make it easy to paste it on an email, word processor, or some other software.
Installing pyperclip:
pip install pyperclip
To copy text to the clipboard, pass a string to pyperclip.copy()
. To paste the text from the clipboard, call pyperclip.paste()
and the text will be returned as a string value.
Code 1:
import pyperclip as pc
text1 = "GeeksforGeeks"
pc.copy(text1)
text2 = pc.paste()
print (text2)
|
Output :
GeeksforGeeks
Code 2:
import pyperclip as pc
number = 100
pc.copy(number)
text = pc.paste()
print (text)
print ( type (text))
|
Output :
100
Note : Copy function will convert every data type to string.
Last Updated :
27 Feb, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...