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)如何在PageNumList中搜索NR0951113?在
2)如果我想得到NR0951113数组索引?如何得到它?在
我想你可能想要:
如果您确实想获得索引,那么^{} 可能是您应该使用的内置项:
^{pr2}$如果在任何对象上找不到设备ID,则将引发
StopIteration
。您可以通过向next
传递第二个值来防止StopIteration
,如果传入的iterable为空,则返回该值:相关问题 更多 >
编程相关推荐