try :
import csv
import urllib.request
from io import StringIO
target_url = 'https://raw.githubusercontent.com/vaastav/Fantasy-Premier-League/master/data/2022-23/gws/gw1.csv'
with urllib.request.urlopen(target_url) as csv_file:
data = StringIO(csv_file.read().decode('utf-8'))
csv_reader = csv.DictReader(data)
players = list(csv_reader)
print(players)
打印:
[
{'name': 'Nathan Redmond', 'position': 'MID', 'team': 'Southampton', 'xP': '1.5', 'assists': '0', 'bonus': '0', 'bps': '3', 'clean_sheets': '0', 'creativity': '0.0', 'element': '403', 'expected_assists': '0.00000', 'expected_goal_involvements': '0.00000', 'expected_goals': '0.00000', 'expected_goals_conceded': '0.00000', 'fixture': '8', 'goals_conceded': '0', 'goals_scored': '0', 'ict_index': '0.0', 'influence': '0.0', 'kickoff_time': '2022-08-06T14:00:00Z', 'minutes': '1', 'opponent_team': '18', 'own_goals': '0', 'penalties_missed': '0', 'penalties_saved': '0', 'red_cards': '0', 'round': '1', 'saves': '0', 'selected': '5871', 'starts': '0', 'team_a_score': '1', 'team_h_score': '4', 'threat': '0.0', 'total_points': '1', 'transfers_balance': '0', 'transfers_in': '0', 'transfers_out': '0', 'value': '55', 'was_home': 'False', 'yellow_cards': '0'},
...