我有这样一个清单:
list=[[lsn,tid,status,type,item,AFIM,BFIM],[1,1,Active,Read,X,-,-],[2,1,Active,Write,X,2,0],....and so on]
现在我有一个变量
tid=1
我想在“list”中搜索tid匹配的列表,状态应该是“Write”。我试着这样做,但没有任何结果。。。。。你知道吗
for id, stat in list/enumerate(list):
if id == tid and stat == 'Write':
print list
拆分列表有帮助吗??你知道吗
不,分开也没用。你知道吗
可以使用list comprehensions和动态named tuples:
注释
list
这样的内置函数之后调用变量—这通常会导致混淆或bug。你知道吗你是说这样的事吗?你知道吗
也可以使用namedtuples:
相关问题 更多 >
编程相关推荐