因此,我正在处理一个在Python中使用Construct模块的项目。我试图访问一个容器中的值,但是却抛出了一个错误
为了得到下面的语句,我使用了types[i].fieldlist
**Container Structure:**
length = 90
tpi_idx = 4407
leaf_type = (enum) LF_FIELDLIST 4611
substructs = ListContainer
Container:
leaf_type = (enum) LF_MEMBER 5389
....
到目前为止我已经试过了
`str(types[i].fieldlist.length)` = AttributeError: 'EnumIntegerString' object has no attribute 'length'
`str(types[i].fieldlist[0]) = Just returns 'T'
`str(types[i].fieldlist['length'] = Sting indices must be integers
代码如下所示:
for i in types:
if types[i].leaf_type == "LF_FIELDLIST":
types[i].substructs = ListContainer([resolve_typerefs(t, types, min) for t in types[i].substructs])
# f.write(str(types[i].substructs))
elif types[i].leaf_type == "LF_STRUCTURE":
if types[i].name == "stack_st":
types[i] = resolve_typerefs(types[i], types, min)
#
# items = types[i].items()
# # for k, v in items:
# # print(str(k), str(v))
f.write(str(types[i]))
# print(types[i])
print(str(types[i].fieldlist['length']))
else:
types[i] = resolve_typerefs(types[i], types, min)
到目前为止我已经试过了
str(types[i].fieldlist.length)
=AttributeError:'EnumIntegerString'对象没有属性'length'
`str(types[i].fieldlist[0])=仅返回'T'
`str(types[i].fieldlist['length']=Sting索引必须是整数
目前没有回答
相关问题 更多 >
编程相关推荐