首先安装一个 goto 的包(因为官方是没有 goto 语句的)

pip install goto-statement

具体的语法

from goto import with_goto
     
@with_goto
def range(start, stop):
      i = start
      result = []
     
      label .begin
      if i == stop:
          goto .end
     
      result.append(i)
      i += 1
      goto .begin
     
      label .end
      return result
收藏 打印