すべて編集
import struct
from collections import namedtuple
FDResult = namedtuple('FDResult', ['DeviceID', 'PageNum'])
#bla = [FDResult(DeviceID='NR0951113', PageNum=[1,2,3,4]),
#FDResult(DeviceID='NR0951114', PageNum=[17,28,63,64]),
#FDResult(DeviceID='NR0951115', PageNum=[2,3,4,5])]
bla = [FDResult(DeviceID='NR0951115', PageNum=[1])] #how to declare bla as FDResult array and blank data inside,Length of bla should equal 0
bla.append(FDResult(DeviceID='NR0951112', PageNum=[2]))
print(len(bla))
bla[0].PageNum.append(16)
Pythonで構造体の配列を宣言する方法は?
FDResult配列と内部の空白データ、blaの長さは0に等しい必要があります
答え
FDResult = namedtuple('FDResult', ['DeviceID', 'PageNum'])
#bla = [FDResult(DeviceID='NR0951113', PageNum=[1,2,3,4]),
#FDResult(DeviceID='NR0951114', PageNum=[17,28,63,64]),
#FDResult(DeviceID='NR0951115', PageNum=[2,3,4,5])]
NodeList = []
Node = FDResult(DeviceID='NR0951113', PageNum=[1,2,3,4])
NodeList.append(Node)
print(len(NodeList))
NodeList[0].PageNum.append(16)