代碼:
import csv
from matplotlib import pyplot as plt
arr=[]
arrmin=[]
date=[]
with open(r'C:\Users\Administrator\Desktop\新建文本文檔 (3).csv') as cs:
read=csv.reader(cs)
header=next(read) #next()函數返回文件的下一行,這里只調用一次就返回第一行,同時因為對read調用了一次next,所以之后的read讀取會從第二行開始
row=0
for i in read:
arr.append(int(i[0])) #提取csv文件里面的第一列數據
arrmin.append(int(i[1])) #提取csv文件里面的第二列數據
date.append(int(i[2])) #提取csv文件里面的第三列數據
print(header)
print(arr)
print(date)
plt.plot(date,arr,c='yellow')
plt.plot(date,arrmin,c='red')
plt.show()