python结果数据如何输出为期望的格式?
test7.rar
(7.97 KB)
程序代码:
if __name__ == '__main__': src_data=pd.read_excel('./sample portfolio.xlsx',header=0,nrows=5,usecols=['ETF代码']) # print(src_data) res_list=[] curr_date=time.strftime("%Y-%m-%d", time.localtime()) for index,gupiao_name in src_data.items(): for gpname in gupiao_name: tem_name=gpname[0:6] tem_list=get_news(tem_name,curr_date) res_list.append(tem_list) # print(res_list) df=pd.DataFrame(res_list) writer=pd.ExcelWriter('test8.xlsx',engine='xlsxwriter') df.to_excel(writer,sheet_name='结果',index=False) writer.save()