我有以下2所列出:Python的比較2所列出
# a unicode list
A= ["[u'899', u'1395']", "[u'908', u'2905']", "[u'423', u'2807']", "[u'440', u'9467']", "[u'430', u'722']", "[u'427', u'1700']", "[u'444', u'1696']", "[u'443', u'2672']", "[u'1049', u'2099']", "[u'916', u'2316']", "[u'923', u'921']", "[u'905', u'1172']", "[u'1025', u'786']", "[u'433', u'896']", "[u'426', u'1628']", "[u'961', u'732']", "[u'922', u'944']", "[u'434', u'11981']", "[u'1058', u'1429']", "[u'1056', u'1761']", "[u'896', u'1548']", "[u'432', u'3015']", "[u'974', u'805']", "[u'1091', u'2654']", "[u'1098', u'212']", "[u'976', u'694']", "[u'949', u'742']", "[u'1048', u'752']", "[u'900', u'1574']", "[u'852', u'668']", "[u'466', u'1545']", "[u'925', u'1030']", "[u'435', u'1298']", "[u'1064', u'853']", "[u'431', u'2879']"]
# Type list
B= [[423L, '$2,779'], [426L, '$1,628'], [427L, '$1,664'], [430L, '$655'], [431L, '$2,658'], [432L, '$3,015'], [433L, '$896'], [434L, '$11,981'], [435L, '$1,298'], [440L, '$9,467'], [443L, '$2,672'], [444L, '$1,696'], [466L, '$1,545'], [787L, '$804'], [852L, '$664'], [896L, '$1,548'], [899L, '$1,395'], [900L, '$1,574'], [905L, '$1,172'], [908L, '$2,886'], [916L, '$2,286'], [922L, '$944'], [923L, '$921'], [925L, '$875'], [934L, '$2,575'], [949L, '$732'], [961L, '$727'], [974L, '$802'], [976L, '$511'], [1025L, '$786'], [1048L, '$752'], [1049L, '$2,099'], [1056L, '$1,761'], [1058L, '$1,417'], [1064L, '$835'], [1072L, '$3,409'], [1091L, '$2,654'], [1098L, '$212']]
我想借第一項在列表A
:"[u'899', u'1395']"
和搜索它在第二個列表。如果找到,則比較這些值並打印如果它們是相同或不同的,並且對列表中的所有其他項目都是相同的。 有人可以幫我嗎?
就目前來看,這個問題還不清楚。你可以給一些小的列表,這些列表仍然足以證明你的問題,然後讓我們知道你希望你的程序給出什麼答案,以及你目前的程序給你什麼? – ymbirtt
這是你想要的,但是你試過了什麼? –
好的。例如我有這個列表[「[u'899',u'1395']」]這是一個unicode列表和這個列表[[899L,'$ 2,779']],它是一個類型列表。我想遍歷第一個列表並查看If 899是否在另一個列表中。如果它確實比較了899的值(在這種情況下是1395)和另一個列表中的值,並打印它們是否相同。 – Marcio125