2 回答

TA貢獻1946條經驗 獲得超3個贊
我認為您的錯誤在開頭的 for 循環中。你有,for line in ins1但你永遠不會line在循環內使用。在您的循環中,您還使用了之前未定義的number_string和data。
以下是從 txt 文件中提取數據的方法。
with open("bijlage.txt", "r") as ff:
ll = ff.readlines() #extract a list, each element is a line of the file
data = []
for line in ll[1:]: #excluding the first line wich is an header
d = line.split(';')[5] #split each line in a list using semicolon as a separator and keep the element with index 5
data.append(float(d.replace(',', '.'))) #substituting the comma with the dot in the string and convert it to a float
print data #data is a list with all the numbers you want
您應該能夠從這里計算均值和標準差。
添加回答
舉報