限定符 [0][1] 有什么作用?
What do the qualifiers [0][1] do?
请考虑下面编译运行的代码
import numpy as np
tgt = np.array([3,5,8,10,12,15])
num_guesses = 10
results =[]
for g in range(num_guesses):
guess = np.random.uniform(low = tgt.min(), high = tgt.max())
total_dist = np.sum((tgt-guess)**2)
results.append((total_dist, guess))
best_guess = sorted(results)[0][1]
print(best_guess)
有人可以解释限定符 [0][1]
是如何得出 best_guess
结果的吗?谢谢
请考虑下面编译运行的代码
import numpy as np
tgt = np.array([3,5,8,10,12,15])
num_guesses = 10
results =[]
for g in range(num_guesses):
guess = np.random.uniform(low = tgt.min(), high = tgt.max())
total_dist = np.sum((tgt-guess)**2)
results.append((total_dist, guess))
best_guess = sorted(results)[0][1]
print(best_guess)
有人可以解释限定符 [0][1]
是如何得出 best_guess
结果的吗?谢谢