0
我收到return json_run(url, data)
行的語法錯誤,我找不到原因。返回語句中的語法錯誤
from urllib.request import urlopen
from json import loads as json_loads
import time
from urllib.error import HTTPError
import random
def json_run(url, data) :
s = url + data
try:
r = urlopen(s)
o = json_loads(r.read().decode('utf8'))
return o
except HTTPError as err:
if err == 504:
# Retry
time.sleep(random.randint(1, 10)
return json_run(url, data)
else:
raise