擅长:python、mysql、java
<p>使用Python的<a href="https://docs.python.org/3/library/csv.html" rel="nofollow noreferrer">csv</a>读取功能:</p>
<pre><code>import csv
with open('csv_file.txt', 'r', newline='') as f:
reader = csv.DictReader(f, ('club', 'city', 'country'))
clubs = list(reader)
print(clubs)
# [{'club': 'Manchester United', 'city': ' Manchester', 'country': 'UK'}, {'club': 'Real Madrid', 'city': 'Madrid', 'country': 'Spain'}, {'club': 'Juventus', 'city': 'Turin', 'country': 'Italy'}]
</code></pre>