importmatplotlib.pyplotaspltimportmatplotlib.financeasmpfwithopen('SH#600004.txt')asobj:text=obj.readlines()#vol成交量amo成交额baseinfo=text[0]dayinfo=text[2:-1]date_list...
import matplotlib.pyplot as plt
import matplotlib.finance as mpf
with open('SH#600004.txt') as obj:
text=obj.readlines()
# vol 成交量 amo成交额
baseinfo=text[0]
dayinfo=text[2:-1]
date_list =[dayinfo[i].split(',')[0] for i in range(len(dayinfo))]
open_list =[dayinfo[i].split(',')[1] for i in range(len(dayinfo))]
high_list =[dayinfo[i].split(',')[2] for i in range(len(dayinfo))]
low_list =[dayinfo[i].split(',')[3] for i in range(len(dayinfo))]
close_list=[dayinfo[i].split(',')[4] for i in range(len(dayinfo))]
quotes=zip(date_list,open_list,high_list,low_list,close_list)
#N=100
#open_list[:N],high_list[:N],low_list[:N],close_list[:N]
fig,ax=plt.subplots()
mpf.candlestick_ohlc(ax,quotes,width=0.6,colorup='r',colordown='green')
plt.title(baseinfo)
plt.xlabel(date_list)
plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus']=False #用来正常显示负号
plt.show()
#报错信息
#TypeError: unsupported operand type(s) for -: 'str' and 'str'
请问应该怎么改
展开