我有一个写在 excel 文件中的输出。我的值是浮点数,在 python 中,浮点数是点(1/3 = 0.33),但在 excel 中浮点数是逗号(0,33)。如何将所有点转换为逗号......................................................?
import math
print("\nThis program calculates the maximum height and speed of a one stage rocket \n")
Isp = float(input("Write Specific Impulse in seconds = "))
min = float(input("Write the initial mass of the rocket ="))
mfuel = float(input("Write tha mass of fuel = "))
mf = float(input("Write the final mass of the rocket = "))
tb = float(input("Write the time that rockets fuel ends = "))
file = open("Ask_2_AET.csv", "w")
file.write("h in meters")
file.write(";")
file.write("V in m/s")
file.write(";")
file.write("t in seconds\n")
g = 9.81
t = 0.000001
Ve = g * Isp
while t == tb or t < tb:
mt = min - mfuel * (t/tb)
y = g * (-t * Isp * (math.log(min/mt) / ((min/mt) - 1)) + t * Isp - 1/2 * t ** 2)
V = Ve * math.log(min / mt) - g * t
t = round(t)
file.write(str(round(y, 2)))
file.write(";")
file.write(str(round(V, 2)))
file.write(";")
file.write(str(round(t)))
file.write("\n")
t += 1
Vb = V
while V > 0:
V = Vb - g * t
h = Vb * t - 1 / 2 * g * t ** 2
if V > 0:
file.write(str(round(h, 2)))
file.write(";")
file.write(str(round(V, 2)))
file.write(";")
file.write(str(round(t)))
file.write("\n")
t += 1
else:
break