Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/323.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 错误类型:应为range()整数结束参数,获得LP_c_ulong_Python_Ctype - Fatal编程技术网

Python 错误类型:应为range()整数结束参数,获得LP_c_ulong

Python 错误类型:应为range()整数结束参数,获得LP_c_ulong,python,ctype,Python,Ctype,尝试将“slots_num”用作range()中的参数时出现此错误: 我做错了什么?内置函数 范围构造函数的参数必须是整数(内置int或实现索引的任何对象) 但您提供了一个实例 >>> import ctypes >>> p = ctypes.pointer(ctypes.c_uint32(2)) >>> for i in range(0, p):print(i) ... Traceback (most recent call last):

尝试将“slots_num”用作range()中的参数时出现此错误:

我做错了什么?

内置函数

范围构造函数的参数必须是整数(内置int或实现索引的任何对象)

但您提供了一个实例

>>> import ctypes
>>> p = ctypes.pointer(ctypes.c_uint32(2))
>>> for i in range(0, p):print(i)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'LP_c_uint' object cannot be interpreted as an integer
内置功能

范围构造函数的参数必须是整数(内置int或实现索引的任何对象)

但您提供了一个实例

>>> import ctypes
>>> p = ctypes.pointer(ctypes.c_uint32(2))
>>> for i in range(0, p):print(i)
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'LP_c_uint' object cannot be interpreted as an integer
>>> d = p.contents.value
>>> d
2
>>> for i in range(0, d):print(i)
... 
0
1