StructPageNum = namedtuple('FDResult', ['DeviceID', 'PageNum'])
PageNumList = 
Node = StructPageNum(DeviceID='NR0951113', PageNum=[1,2,3,4])
Node = StructPageNum(DeviceID='NR0951114', PageNum=[1,2,3,4])
print('NR0951113' in PageNumList[:].DeviceID)
1)how to search NR0951113 whether in the PageNumList or not?
2)if i want to get the NR0951113 array index?how to get it?
I think you probably want:
any(x.DeviceID == 'NR0851113' for x in PageNumList)
If you actually want to get the index, then possibly
next is the builtin you should be using:
next(i for i,x in enumerate(PageNumList) if x.DeviceID == 'NR085113')
This will raise
StopIteration if the DeviceID isn't found on any of your objects. You can prevent the
StopIteration by passing a second value to
next which is returned if the iterable you pass in is empty:
index = next((i for i,x in enumerate(PageNumList) if x.DeviceID == 'NR085113'),None) if index is not None: ...