def data_write(file_path, datas):
f = xlwt.Workbook()
sheet1 = f.add_sheet(u'sheet1',cell_overwrite_ok=True) #创建sheet
#将数据中棚写入第 i 行,第 j 列卖派则
i = 0
for data in datas:
for j in range(len(data)):
sheet1.write(i,j,data[j])
i = i + 1
f.save(file_path) #保存文件羡仔
def writeToTxt(list_name,file_path):try:
fp = open(file_path,"w+")
for item in list_name:
fp.write(str(item)+"\n")//毁困薯list中纤者一项占一行尺轿
fp.close()
except IOError:
print("fail to open file")
if __name__ == "__main__":
list_name = [ 3.00008000 +0.j,-10.58085662-19.4778165j,5.87334700 +4.733817j, -0.86048738 -0.5688545j,17.35029000 +0.j,-0.86048738 +0.5688545j,5.87334700 -4.733817j,-10.58085662+19.4778165j] //你的list
file_path = r"hello.txt"
writeToTxt(list_name,file_path)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)