如何在Python中计算文本文件的总和绝对值?
time = np.loadtxt("data.svc",delimiter=' ',skiprows=1, usecols=(2),unpack=True)
for i in range(len(time)):
sumTime = sum(abs(time[i]-time[i+1]))
Run Code Online (Sandbox Code Playgroud)
我需要:(|time[0]-time[1]|)+(|time[1]-time[2]|)+(|time[2]-time[3]|)....