新到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'必須每次增加。對不起,#必須刪除。 –