0
無效語法我有這樣的Python代碼在這裏:的Python有條件
def location(location_id, max_id=None):
# Send http request to find location
if (self.login_status):
get_location = {'location_id': location_id}
url_location_detail = self.url_location_detail % (location_id)
try:
get_location_id = self.i.get(url_location_detail, data=body)
if location.status_code == 200:
log_string = "Get location id: %d" % (location_id)
self.write_log(log_string)
if max_id is not None: payload['max_id'] = max_id
try:
res = requests.get(url, params=payload).json()
body = res['location']
cursor = res['location']['media']['page_info']['end_cursor']
except: raise
return InstagramExploreResponse(data=body, cursor=cursor)
當我運行程序,它會引發以下錯誤:
SyntaxError: invalid syntax
的錯誤似乎在線路447現身這是以下內容:
if max_id is not None: payload['max_id'] = max_id
奇怪的是,代碼工作之前,我在這行之前添加了一些代碼,所以我認爲這個錯誤來自上一行。
不幸的是,我看不到它。
謝謝!
感謝。我檢查了你的鏈接,但是我找不到我的問題的答案。你能在我的代碼中提出一個語法錯誤嗎?因爲在添加其他行之前找到了它,並且從未提出過無效的語法。 – justinedps26
我剛編輯答案。現在應該更容易看到 – Xidh