使用excel时 使用cmd打开命令界面后 输入 pip install openpyxl 进行在线安装
将txt文件中的导入到excel中
import openpyxl as op import json file="e://stock01.txt" b={} with open(file,"r") as f: content=f.readlines() # print("content",content) for x in content: if x!="\n": c=x.split("(") d=c[0] e=c[1].replace(")\n","") b[e]=d wb=op.Workbook() sheet1=wb.active sheet1.title="yy" for i,(j,k)in enumerate(b.items()): sheet1.cell(row=i+1,column=1,value=j) sheet1.cell(row=i+1,column=2,value=k) wb.save("e://test10.xlsx")