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