how to read data from clipboard and pass it as value to a variable in python?
Question: how to read data from clipboard and pass it as value to a variable in python?

For example:

I will copy some data {eg: 200} by pressing ctrl+c or through rightclick. and
pass it to a variable.

c = 200

..can any1 tel me how to do this?


Answer: To read from clipboard in your script with tkinter is this easy:

    
    
    try:
        # Python2
        import Tkinter as tk
    except ImportError:
        # Python3
        import tkinter as tk
    
    root = tk.Tk()
    # keep the window from showing
    root.withdraw()
    
    # read the clipboard
    c = root.clipboard_get()
    

