Bootstrap

csv 天气数据下载网站NOAA CDO 原创

import csv
import matplotlib.pyplot as plt
from datetime import datetime

filename = 'sitka_weather_2018_simple.csv'
with open(filename) as f:
    reader = csv.reader(f)
    header_row = next(reader)
    # print(header_row)
    #    for index,column_header in enumerate(header_row):
    #       print(index,column_header)
    dates, highs, lows = [], [], []
    for row in reader:
        high = int(row[5])
        highs.append(high)
        date = datetime.strptime(row[2], '%Y-%m-%d')
        dates.append(date)
        low = int(row[6])
        lows.append(low)
# print(highs)
plt.style.use('seaborn')
fig, ax = plt.subplots()
ax.plot(dates, highs, c='red')
ax.plot(dates, lows, c='blue')
ax.fill_between(dates, highs, lows, facecolor='yellow')
ax.set_title('最高气温', fontsize=25)
ax.set_xlabel('', fontsize=15)
fig.autofmt_xdate()
ax.set_ylabel('气温', fontsize=15)
ax.tick_params(axis='both', which='major', labelsize=15)
plt.show()



#数据缺失可用 try-except-else

悦读

道可道,非常道;名可名,非常名。 无名,天地之始,有名,万物之母。 故常无欲,以观其妙,常有欲,以观其徼。 此两者,同出而异名,同谓之玄,玄之又玄,众妙之门。

;