是否可以匹配兩個元組,逐個比較每個元素,並確定發生了什麼變化。比較列表中的每個元素
注意: runA和runB輸出在循環中,所以這意味着它不是硬編碼的。 runA和runB的範圍可以是tool01到tool100或tool01等,這取決於循環結果到我的查詢。只是簡單的工具是在for循環中,所以工具no可以更多或更少。的我的輸出#1
實施例的結果:
runA = [(u'tool01', '21'), (u'tool02', '22'), (u'tool03', '23')]
runB = [(u'tool01', '21'), (u'tool02', '22'), (u'tool03', '22')]
預期結果#1:我的輸出#2
print 'there is a changes on tool03'
實施例的結果:
runA = [(u'tool01', '21'), (u'tool02', '22'), (u'tool03', '23')]
runB = [(u'tool01', '20'), (u'tool02', '21'), (u'tool03', '23')]
預期結果#2 :
print 'there is a changes on tool01'
print 'there is a changes on tool02'
012的我的輸出#
實施例的結果:
runA = [(u'tool01', '21'), (u'tool02', '22'), (u'tool03', '23')]
runB = [(u'tool01', '21'), (u'tool02', '22'), (u'tool03', '23')]
預期結果#3:
print 'there is no change'
任何建議或基礎碼,由於事先。
注意: runA和runB輸出在循環中,所以這意味着它不是硬編碼的。 runA和runB的範圍可以是tool01到tool100或tool01等,這取決於循環結果到我的查詢。只是簡單的工具是在for循環中,所以工具no可以更多或更少。
有沒有理由不能使用字典? – user3846506
編寫這樣的代碼當然是可能的,但Stack Overflow不是代碼寫入服務。你有什麼嘗試?如果您在初次嘗試時遇到問題,請描述問題,我們會盡力爲您提供幫助。 – Blckknght
是可以使用字典。我會盡力。 @Blckknght,我只是發佈我的關注,以便在Im編碼時,這個會話也可以作爲我的備份幫助。 –