求解答关于数据无法成功写入.csv文件
程序代码:
with open("result1.csv","w") as csvfile: data=[] data.append(1) data.append(2) data.append(3) #datas=[] writer = csv.writer(csvfile) writer.writerow(["a","b","c"]) for x in range(1,10000): for y in range(1,10000): if (zhishu(x,y)==1 and z<=10000) : z = math.sqrt(x*x+y*y) n=int(z) if ((z-float(n))==0): #writer.writerow([x,y,n]) data[0]=x data[1]=y data[2]=n print(x,y,n) #print(data) writer.writerow(data)
data值正确,但是无法正常写入csv文件,求解