Python 3: 날씨 정보 얻 기
파 이 썬 버 전
Python3.5.3
일기예보 웹 서비스 참고
http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?op=getWeatherbyCityName
주의: 이 서 비 스 는 3 일간 의 일기 예 보 를 표시 할 수 있 습 니 다.
import urllib.request
from xml.dom.minidom import parseString
url = "http://www.webxml.com.cn/WebServices/WeatherWebService.asmx/getWeatherbyCityName?theCityName"
while True:
CityName = input(" ( q ):")
if CityName == 'q':
break
values = {"theCityName": CityName}
data = urllib.parse.urlencode(values).encode(encoding='UTF8')
req = urllib.request.Request(url, data)
response = urllib.request.urlopen(req)
the_page = response.read().decode("utf8")
dom = parseString(the_page)
W_data = dom.getElementsByTagName("string")
i = 1
for w in W_data:
try:
data = w.childNodes[0].data
print(data)
except IndexError as err:
print(" !")
실행 결과:
( q ):
54511
54511.jpg
2017-8-13 17:53:46
23℃/29℃
8 13
4.gif
4.gif
: :22℃; / : 1 ; :90%; : 。 : 。
: , , SPF12-15、PA+ 。
: , , 。
: , T 、 。
: , , 。
: , , 。
: , 。
22℃/30℃
8 14
1.gif
1.gif
22℃/31℃
8 15
1.gif
4.gif
, 39 , 116 , , 。 , 12 6 , 1100 。 , , , 、 , 10-12 。 。 , “ ”。 , “ ”。 1045 、 ; 221 , ; 938 , 、 、 、 。1949 10 1 ××× 。 , 200 , 、 、××× 、××× , 、 、 。 7309 , 42 , 222 。 , 。 , 、 、 、 。
( q ):
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
AWS EC2(Amazon Linux 2) 서버에서 Apache2.4, Python3, wsgi 실행 환경 구축Amazon Linux 2에는 처음부터 Python2가 포함되어 있지만 Python3 및 wsgi 환경을 구축합니다. 먼저 Apache2.4를 설치합니다. 그런 다음 python3을 설치합니다. ※이 문장의 작성 시...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.