请问各位大神这段代码,中文无法显示,这么解决!
import csv
import matplotlib.pyplot as plt
from pylab import *#显示中文字符代码
mpl.rcParams["font.sans-serif"]=["SimHei"]#显示中文字符代码
from datetime import datetime
filename ="sitka_weather_2018_simple.csv"
with open(filename) as f:
reader = csv.reader(f)
header_row = next(reader)
dates,highs,lows = [],[],[]
for row in reader:
current_date = datetime.strptime(row[2],"%Y-%m-%d")
try:
high = int(row[5])
low = int(row[6])
except:
print(f"missing data of {current_date}")
else:
highs.append(high)
lows.append(low)
dates.append(current_date)
plt.style.use("seaborn")
fig,ax = plt.subplots()
ax.plot(dates,highs,c="red",alpha =0.2)
ax.plot(dates,lows,c="blue",alpha = 0.2)
ax.fill_between(dates,highs,lows,facecolor = "green",alpha = 0.3)
ax.set_xlabel("",fontsize = 15)
fig.autofmt_xdate()
ax.set_ylabel("温度(F)",fontsize= 15)
ax.set_title("2018年度7月份每日最高温度",fontsize=15)
ax.tick_params(axis ="both",which ="major",labelsize = 15)
plt.show()