因為只需要右轉from itertools import cycleright_turn = cycle(((0, 1), (1, 0), (0, -1), (-1, 0))).__next__di, dj = right_turn() # 初始化# 要右轉就呼叫一次di, dj = right_turn()
from itertools import cycle
right_turn = cycle(((0, 1), (1, 0), (0, -1), (-1, 0))).__next__
di, dj = right_turn() # 初始化
# 要右轉就呼叫一次
di, dj = right_turn()