文件名称:历史天气爬虫
文件大小:3KB
文件格式:PY
更新时间:2022-02-14 15:34:11
python
# 可以这么用 weather = Weather_2345('广州', '201811', '201901') print(weather.get_weather()) # 也可以这么用 weather = Weather_2345('下面会再次设置区域这里可以随便填', '201811', '201901') area_list = ["白云", "从化", "花都", "海珠", "黄埔", "荔湾", "南沙", "番禺", "天河", "越秀", "增城"] with open('./weather.log', 'w', encoding='utf-8') as fw: fw.write("区域,日期,最高气温,最低气温,天气,风向,风力,空气指数,空气情况,空气等级" + "\n") for area in area_list: print() weather.area = area weather_list = weather.get_weather() for lines in weather_list: fw.write(",".join(lines) + '\n')