banaandrew

Untitled

Nov 18th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. def get_result(url: str) -> dict:
  2.     '''
  3.    This function takes a URL and returns a Python dictionary representing the
  4.    parsed JSON response.
  5.    '''
  6.     response = None
  7.  
  8.     try:
  9.         response = urllib.request.urlopen(url)
  10.  
  11.         return json.load(response)
  12.  
  13.     finally:
  14.         if response != None:
  15.             response.close()
Advertisement
Add Comment
Please, Sign In to add comment