python - IndexError,Python 绘图
问题描述
import csv
import os
from matplotlib import pyplot as plt
os.chdir('C:\\Users\\alpha\\Desktop\\sitka')
filename = 'sitka_weather_history.csv'
with open(filename) as f:
reader=csv.reader(f)
header_row = next(reader)
highs=[]
for row in reader:
high=int(row[1])
highs.append(row[1])
fig= plt.figure(dpi=123, figsize=(10, 6))
plt.plot(highs)
plt.show()
我的错误信息显示
IndexError:列表索引超出范围
我不确定为什么会收到此错误以及我做错了什么,如果有人可以告诉我。我会很感激!
解决方案
推荐阅读
- ruby - 如何使用.include?捕获导致相同操作的多个选项
- php - 如何对“私有”构造函数进行例外处理?
- java - 如何在 Java 8 的范围内生成具有指定大小的随机整数的列表?
- c# - Unity3D 引擎类中不应该出现一致的“CS0201”错误
- regex - 如何计算最后出现在单元格中的Google表格单元格中特定字符的出现次数作为标准?
- java - 不兼容的类型。必需:T,找到 T。为什么?
- excel - 如何让 Excel 用户表单验证然后编辑用户表单
- java - SpringBootTest 和 MockMvc 创建了大量控制台日志记录 - 如何禁用?
- javascript - 异步命名箭头函数错误“意外令牌”
- javascript - 使用 Javascript 获取用户位置