Advertisement
Fhernd

clase_como_funcion.py

Sep 29th, 2018
7,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. from urllib.request import urlopen
  2.  
  3. def plantilla_url(plantilla):
  4.     def abrir(**kwargs):
  5.         return urlopen(plantilla.format_map(kwargs))
  6.  
  7.     return abrir
  8.  
  9.  
  10. clima = plantilla_url('https://samples.openweathermap.org/data/2.5/forecast?id={id}&appid=b1b15e88fa797225412429c1c50c122a1')
  11. for linea in clima(id='524901', appid='b1b15e88fa797225412429c1c50c122a1'):
  12.     print(linea.decode('utf-8'))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement