Python3中有没有像c++那样的goto语句(或者功能相同的语句,即无条件跳转语句)
python没有原生goto语句,需要安装第三方库。
安装: pip3 install goto-statement
@with_goto
def get_response(i):
label .begin
print(i)
site = "XXX"
r = urllib.request.Request(site, headers=hdr)
try:
response = urllib.request.urlopen(r,timeout=10)
except:
goto .begin
return response
python里面 “ try except finally” 关键字与goto类似
望采纳