擅长:python、mysql、java
<p>如果需要最高分,那么使用<a href="https://docs.python.org/3/library/functions.html#max" rel="nofollow">^{<cd1>}</a>函数</p>
<pre><code>>>> from collections import defaultdict
>>> data = defaultdict(list)
>>> with open('StudentsScoreA.txt') as f:
... for line in f:
... name, score = line.split()
... data[name].append(int(score))
...
>>> for name, score in data.items():
... print('{} your score was {}'.format(name, max(score)))
...
eddie your score was 7
lenard your score was 10
max your score was 5
james your score was 4
zack your score was 3
</code></pre>