Python Pyperclip – Paste clipboard to dictionary

In this post we will be creating a Python script that will paste the contents of the clipboard to a dictionary. To do this we will use the Pyperclip module which enables us to copy and paste clipboard functions.

See the sample of Python code below where we paste our clipboard to a dictionary, in this example we utilize the ‘json.dumps()’ which assists in the conversion to a dictionary.

import pyperclip
import json

text_from_clipboard = pyperclip.paste()
my_dict = json.loads(text_from_clipboard)
print(my_dict)

Take a look at some of our other content around the Python programming language by clicking here.

Leave a Reply