您正在使用局部变量 i 同时也发生了变化。 像这样传递:
i
threading.Thread(target=loop, args=(i,))
并将其作为参数添加到 loop 功能:
loop
def loop(i): ...