0
私はこのようになりますリストがあります:私はこのような何かを探していますので、一意の値が各項目の最初の要素をODF取得したいリストの最初の要素の一意の値を取得するにはどうすればよいですか?
l=[(['amandviw'], ['09.01'], [11, 0, 0, 0, 0]), (['amandviw'], ['09.03'], [6, 0, 5, 0, 0]), (['amandviw'], ['10.01'], [10, 0, 0, 0, 1]), (['amandviw'], ['10.02'], [10, 0, 0, 0, 1]), (['amandviw'], ['10.03'], [10, 0, 1, 0, 0]), (['amandviw'], ['10.05'], [16, 4, 2, 0, 1]), (['amandviw'], ['10.06'], [23, 0, 0, 0, 0]), (['amandviw'], ['10.07'], [8, 0, 0, 0, 3]), (['archerj'], ['09.01'], [0, 0, 0, 0, 0]), (['archerj'], ['09.03'], [0, 0, 0, 0, 0]), (['archerj'], ['10.01'], [0, 0, 0, 0, 0]), (['archerj'], ['10.02'], [0, 0, 0, 0, 0]), (['archerj'], ['10.03'], [0, 0, 0, 0, 0]), (['archerj'], ['10.05'], [0, 1, 0, 0, 0]), (['archerj'], ['10.06'], [1, 0, 0, 0, 0]), (['archerj'], ['10.07'], [0, 0, 0, 0, 0]), (['dwickett'], ['09.01'], [9, 0, 2, 0, 1]), (['dwickett'], ['09.03'], [5, 1, 0, 0, 6]), (['dwickett'], ['10.01'], [12, 0, 0, 0, 0]), (['dwickett'], ['10.02'], [10, 0, 2, 0, 0]), (['dwickett'], ['10.03'], [11, 0, 0, 0, 1]), (['dwickett'], ['10.05'], [13, 4, 2, 0, 6]), (['dwickett'], ['10.06'], [21, 1, 0, 0, 3]), (['dwickett'], ['10.07'], [8, 0, 3, 0, 1]), (['gandhi7'], ['09.01'], [27, 0, 0, 0, 1]), (['gandhi7'], ['09.03'], [28, 0, 0, 0, 0]), (['gandhi7'], ['10.01'], [27, 0, 0, 0, 1]), (['gandhi7'], ['10.02'], [27, 0, 0, 0, 1]), (['gandhi7'], ['10.03'], [26, 0, 1, 0, 1]), (['gandhi7'], ['10.05'], [37, 9, 3, 0, 8]), (['gandhi7'], ['10.06'], [55, 1, 0, 0, 1]), (['gandhi7'], ['10.07'], [15, 0, 10, 0, 3]), (['lammp'], ['09.01'], [12, 0, 0, 0, 3]), (['lammp'], ['09.03'], [13, 0, 0, 0, 2]), (['lammp'], ['10.01'], [12, 0, 0, 0, 3]), (['lammp'], ['10.02'], [12, 0, 0, 0, 3]), (['lammp'], ['10.03'], [12, 0, 0, 0, 3]), (['lammp'], ['10.05'], [17, 3, 2, 0, 9]), (['lammp'], ['10.06'], [26, 0, 1, 0, 4]), (['lammp'], ['10.07'], [5, 0, 4, 0, 6]), (['lee1131'], ['09.01'], [9, 0, 0, 0, 1]), (['lee1131'], ['09.03'], [7, 0, 1, 0, 2]), (['lee1131'], ['10.01'], [9, 0, 0, 0, 1]), (['lee1131'], ['10.02'], [9, 0, 0, 0, 1]), (['lee1131'], ['10.03'], [8, 0, 1, 0, 1]), (['lee1131'], ['10.05'], [16, 1, 2, 0, 2]), (['lee1131'], ['10.06'], [20, 0, 0, 0, 1]), (['lee1131'], ['10.07'], [7, 0, 2, 0, 1]), (['pzibley'], ['09.01'], [7, 2, 0, 0, 1]), (['pzibley'], ['09.03'], [8, 0, 2, 0, 0]), (['pzibley'], ['10.01'], [8, 1, 0, 0, 1]), (['pzibley'], ['10.02'], [9, 0, 0, 0, 1]), (['pzibley'], ['10.03'], [9, 0, 0, 0, 1]), (['pzibley'], ['10.05'], [13, 1, 3, 0, 4]), (['pzibley'], ['10.06'], [16, 0, 1, 0, 4]), (['pzibley'], ['10.07'], [4, 0, 4, 0, 2]), (['qiu58'], ['09.01'], [35, 0, 0, 0, 1]), (['qiu58'], ['09.03'], [35, 0, 0, 0, 1]), (['qiu58'], ['10.01'], [35, 0, 0, 0, 1]), (['qiu58'], ['10.02'], [35, 0, 0, 0, 1]), (['qiu58'], ['10.03'], [27, 0, 7, 0, 2]), (['qiu58'], ['10.05'], [40, 20, 4, 0, 9]), (['qiu58'], ['10.06'], [58, 13, 0, 0, 2]), (['qiu58'], ['10.07'], [23, 0, 11, 0, 2]), (['yeggy'], ['09.01'], [11, 0, 0, 0, 0]), (['yeggy'], ['09.03'], [10, 0, 0, 0, 2]), (['yeggy'], ['10.01'], [11, 0, 0, 0, 0]), (['yeggy'], ['10.02'], [11, 0, 0, 0, 0]), (['yeggy'], ['10.03'], [10, 1, 0, 0, 0]), (['yeggy'], ['10.05'], [17, 3, 3, 0, 2]), (['yeggy'], ['10.06'], [21, 0, 2, 0, 2]), (['yeggy'], ['10.07'], [6, 0, 5, 0, 1])]
を:
l_unique=('dwickett', 'amandviw', 'yeggy', 'pzibley', 'lammp', 'gandhi7', 'archerj')
このリストのおかげでTigerhawk、 あなたのコードは動作しますが、しかし、私は大きなリストのために同じロジックをしようとすると、エラーがスローされます。 「 はTypeError:非ハッシュの種類: 『リスト』 」 任意のアイデア? – Hossein
@Hossein - はい。 [mcve]を生成する。見えないコードをデバッグするのは難しいです。 – TigerhawkT3
私は質問で更新しました....ありがとう – Hossein