Skip to content

Instantly share code, notes, and snippets.

@masakichi
Created June 20, 2014 02:32
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masakichi/bbe3b3d3ee5f5aecd7d5 to your computer and use it in GitHub Desktop.
Save masakichi/bbe3b3d3ee5f5aecd7d5 to your computer and use it in GitHub Desktop.
World Cup in one line.
import urllib2, json
print '\n'.join([' '.join((jogo['home_team']['country'], str(jogo['home_team']['goals']), 'x', jogo['away_team']['country'], str(jogo['away_team']['goals']))) for jogo in json.loads(urllib2.urlopen('http://worldcup.sfg.io/matches').read().decode('utf-8')) if jogo['status'] == 'completed'])
@xiaket
Copy link

xiaket commented Jun 20, 2014

修改下import, 用requests吧, 还免得显式import json了.

如果写成python -c更好玩.

@masakichi
Copy link
Author

@xiaket 主要requests是外部库。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment