gpt4 book ai didi

Python 3.5.1 (AMD64) ctypes.ArgumentError : argument 1: : int too long to convert

转载 作者:行者123 更新时间:2023-12-05 07:42:50 28 4
gpt4 key购买 nike

我在 WIN32 上使用 Python 3.5.1 (AMD64)

我在 Windows 10 中运行代码有任何关于如何修复错误的建议吗?

ctypes.ArgumentError: argument 1: <class 'OverflowError'>: int too long to convert

最佳答案

对我来说,有两种方法可以防止这种情况发生:

假设我们有这个函数:

USB_GetDeviceInterfaceList(QWORD DeviceId, BYTE *pInterfaceList, DWORD *pdwInterfaceAmount)

这会起作用:

通用共享代码:

from ctypes import *
slibc = 'lib\\usb.dll'
libc = CDLL(slibc)

interface_list = (c_byte * 128)()
interface_amount = c_int()

第一种方法,定义 argtypes:

ctypes.libc.USB_GetDeviceInterfaceList.argtypes = [c_int64, POINTER(c_byte * 128), POINTER(c_int)]
libc.USB_GetDeviceInterfaceList(2425014470954602011, byref(interface_list), byref(interface_amount))

第二种方法,使用类型转换:

libc.USB_GetDeviceInterfaceList(c_int64(2425014470954602011), byref(interface_list), byref(interface_amount))

关于Python 3.5.1 (AMD64) ctypes.ArgumentError : argument 1: <class 'OverflowError' >: int too long to convert,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44163105/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com