Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Which Premier League match should I watch?
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
import http.client import json import math connection = http.client.HTTPConnection('api.football-data.org') connection.request('GET', '/alpha/soccerseasons/354/fixtures', headers={'X-Auth-Token': '3b7ddd493b2c461eb8ba75984800efc3'}) data = json.loads(connection.getresponse().read().decode()) fixtures = (data["fixtures"]) matchday = False fix = 379 while matchday == False: if fixtures[fix]['result']['goalsAwayTeam'] == -1: fix = fix -1 else: matchday = fixtures[fix]['matchday'] dict = {} for key in fixtures: if key["matchday"] == matchday: goals = goal_dif = 0.0 goals = key['result']['goalsAwayTeam'] + key['result']['goalsHomeTeam'] goal_dif = math.fabs(key['result']['goalsAwayTeam'] - key['result']['goalsHomeTeam']) if goal_dif > 0: dict[key['homeTeamName']+" v "+key['awayTeamName']] = goals/goal_dif else: dict[key['homeTeamName']+" v "+key['awayTeamName']] = goals print(sorted(dict, key=dict.get, reverse = True))
[
+
]
Show input
edit mode
|
history
|
discussion