我正在关注教程(http://pyusb.sourceforge.net/docs/1.0/tutorial.html)
我在 windows xp sp3 上,我的 python 版本是 2.7,我下载并安装了 pyusb-1.0.0-a1.zip
和 libusb-win32-bin-1.2.4.0.zip
import usb
工作正常
但
import usb.core
根本不工作
它说
Traceback (most recent call last):
File "D:\py\usb.py", line 1, in <module>
from usb import core
File "D:\py\usb.py", line 1, in <module>
from usb import core
ImportError: cannot import name core
任何解决方案?
谢谢!
ps“从usb导入核心”这个make
Traceback (most recent call last):
File "D:\py\usb.py", line 1, in <module>
from usb import core
File "D:\py\usb.py", line 1, in <module>
from usb import core
ImportError: cannot import name core
完整的源代码在这里
from usb import core
#find device
dev = usb.core.find(idVendor=0x1516, idProduct=0x8628)
#found?
if dev is None :
raise ValueError('device not found')
#set the active config. with no args, the first config will be the active one
dev.set_configuration()
#get an end point instance
ep = usb.util.find_descriptor(
dev.get_interface_altsetting(), #first interface
#match the first Out Endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_OUT)
assert ep is not None
while(1):
ep.write(0x5553424350DDBC880000000000000600000000000000000000000000000000)
ep.write(0x5553425350ddbc880000000000)