类型错误:类型对象不是subscriptab

2024-10-04 09:22:58 发布

您现在位置:Python中文网/ 问答频道 /正文

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)

我收到一个TypeError:“type”对象在行中不可订阅: 距离[n]+=浮动(步幅长度[3]) 你知道我为什么看到这个吗?在


Tags: csvpathdownloadsascounteropenfloatusers