Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Pyperclip module in Python

  • Difficulty Level : Basic
  • Last Updated : 27 Feb, 2020

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:

# importing the library
import pyperclip as pc
text1 = "GeeksforGeeks"
# copying text to clipboard
# pasting the text from clipboard
text2 = pc.paste()

Output :


Code 2:

# importing the library
import pyperclip as pc
number = 100
# copying text to clipboard
# pasting the text from clipboard
text = pc.paste()

Output :


Note : Copy function will convert every data type to string.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!