:Pythonの最大のリストIは次のようにPythonでビルトインMAX()関数を使用してい
max(test_sentences, key=test_sentences.get)
何のために私はそれを使用していますが、リスト内の最大値を見つけることです(test_sentences )。 私は、キーの隣にあるリストの[0]の位置で最大値を持つキーを取り戻したいと思います。 例(PLS 'Uを無視):
{u'my name is tomi': [0, 1, 10, u'my', u'name', u'is', u'tomi'],
u'your name is tomi': [0, 1, 10, u'your', u'name', u'is', u'tomi'],
u'hello bello bye fine': [5, 42, 10, u'hello', u'bello', u'bye', u'fine'],
u'okkay tomi': [1, 1, 10, u'okkay', u'tomi'],
u'fine my name is tomi': [15, 1, 10, u'fine', u'my', u'name', u'is', u'tomi']}
この場合、勝者は、次のようになります。
u'fine my name is tomi'
リストの[0]要素は15であり、これが最大となるように。
実際に私が書いたコードだけで動作します:
max(test_sentences, key=test_sentences.get)
をしかし、私はそれがなぜ...誰かが私を助けて、それを説明していただけます...ただ、ミスを防ぎたいません。
ありがとうございました!