简体   繁体   中英

Win32clipboard Python module installation problem

I am currently having a problem because I cannot use the Win32clipboard library to retrieve the string that is in the clipboard in a variable on python. From what I understand, Win32clipboard is part of the pywin32 library. I managed to install pywin32 after quite a bit of difficulty. So I do import pywin32 at the start of my program. However, when I run my program, python gives me an error, "name 'win32clipboard' is not defined". So I do "import win32clipboard" but still get the same error. I really don't know how to do it. Thanks in advance.

Modification:

This is my code.

import pywin32
import win32clipboard
win32clipboard.OpenClipboard()
data = win32clipboard.GetClipboardData()
win32clipboard.CloseClipboard()
print (data)

and I get this error.

ModuleNotFoundError: No module named 'win32clipboard'

But when I write pip list in the CMD, I found pywin32. Screenshot CMD

I am using spyder 5.1.1 and Python 3.9 Thanks

To use win32clipboard with python 3.9 or 3.10 you have to install the pywin32 library using: pip install pywin32 after which your import line for win32clipboard will look something like this: from win32 import win32clipboard

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM