嗨
我想比较3个列表,每当出现匹配时,列表中的元素都会被删除。你知道吗
(->;每次gpos=G00、xpos=0和ypos=0)
gpos = ['G01','G01','G00','G00','G00','G00','G00','G00','G00','G00']
xpos = ['249','248', '0' , '0' , '72', '0' , '66','67' ,'81' , '82']
ypos = ['18', '28' , '0' , '0' , '52', '0', '53','55' ,'54' , '52']
---------------------
the output should be:
---------------------
gpos = ['G01','G01','G00',G00','G00','G00','G00']
xpos = ['249','248', '72','66','67' ,'81' , '82']
ypos = ['18', '28' , '52','53','55' ,'54' , '52']
我不知道该怎么办
这是相当粗糙的,但它会工作。你知道吗
更重要的是,你至少应该试过一些东西,把它和问题放在一起。不管你错了多少,但你应该尽最大努力自己编写代码。你知道吗
您可以使用来自
itertools
的izip
,并同时迭代您的3个列表。你知道吗然后,当
xpos
和ypos
等于'0'
时,删除元组。你知道吗您可以前后转置它们(考虑列而不是行)并进行筛选。你知道吗
备选方案一班轮(由Blckknght建议):
相关问题 更多 >
编程相关推荐