新到Python
Path = "C:/Users/Kailash/Downloads/Results_For_Stride-Table.csv"
f = open(Path, "r") # as infile: #open("C:/Users/Kailash/Downloads/25ft_output.csv", "w") as outfile:
counter = 0
n = 0
distance = float
print("n =", n)
while True:
counter += 1
#print("Counter = ", counter)
lines = f.readline()
Stride_Length = lines.split(", ")
# if (distance > 762):
# Delta_t = distance
# print("Pre-Delta_t = ", Delta_t)
distance[n] += float(Stride_Length[3])
#n += 1
if distance > 762:
Delta_t = 762 - distance[n - 1]
print("Delta_t = ", Delta_t)
Residual_distance = distance - 762
print("Residual_distance = ", Residual_distance)
counter = 0
distance = Residual_distance
print("Counter & Distance RESET!")
print(distance)
我得到一个类型错误: '类型' 对象未在所述线标化的: 距离[N] + =浮子(Stride_Length [3] ) 任何想法,为什么我看到这个?类型错误:类型对象不是标化的
你可能想用'distance = float(0)'开始?那么,n环路部分应该如何处理距离? – PRMoureu
这个问题的答案是:看看[this](https://stackoverflow.com/questions/26920955/typeerror-type-object-is-not-subscriptable-when-indexing-in-to-a-dictionary)链接。 –
@PRMoureu:我试着用float(0)替换distance = float但是没有解决。 'n'必须每次增加。对不起,#必须删除。 –