May 2018
Beginner to intermediate
452 pages
11h 26m
English
We're going to be creating several functions that access network resources for our application. These functions won't be tied to any particular class, so we'll just put them in their own file called network.py. Let's take a look at the following steps:
from urllib.request import urlopen
def get_local_weather(station):
url = (
'http://w1.weather.gov/xml/current_obs/{}.xml'
.format(station))
response = urlopen(url)
Our function will take a station string as an argument, in case we need to change that later or if someone wants to use this application at a different facility. The function ...