Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/349.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.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
PythoncTypes:从指针变量获取指针类型_Python_Pointers_Types_Structure_Ctypes - Fatal编程技术网

PythoncTypes:从指针变量获取指针类型

PythoncTypes:从指针变量获取指针类型,python,pointers,types,structure,ctypes,Python,Pointers,Types,Structure,Ctypes,我有一个包含基本字段(int,uint8,…)和指针的结构。 这些指针通常指向不同结构类型的数组,以保持深度嵌套的结构。 例如,在C中: struct A { int field1; int field2; struct B *fields3; unsigned int countofb; } struct B { int anotherfield1; int anotherfield2; } 在使用ctypes的python中,我创建了结构a和B的包装器。 迭代结构A的\u

我有一个包含基本字段(int,uint8,…)和指针的结构。 这些指针通常指向不同结构类型的数组,以保持深度嵌套的结构。 例如,在C中:

struct A
{
 int field1;
 int field2;
 struct B *fields3;
 unsigned int countofb;
}

struct B
{
  int anotherfield1;
  int anotherfield2;
}
在使用ctypes的python中,我创建了结构a和B的包装器。 迭代结构A的
\u字段
,我到达第三个字段
field3
,得到类型为
LP\u struct\u B
的ctype变量

问题是,是否有一种方法,一个函数,一种将指针转换为指针类型的ctypes方法

我需要像这样的东西

a=A()
st=pointedtype(a.field3) # or also st = pointedtype2(LP_struct_B)
#desired output: st = struct_B
谢谢

好的。 我已经根据经验找到了答案。 只需使用变量或指针类型的属性
\u type\

a=A()
print a.fields3._type_ # struct_B
tipo=type(a.fields3) # tipo=LP_struct_B
print tipo._type_ # struct_B