【发布时间】:2016-04-14 21:18:35
【问题描述】:
我的python版本是3.5.1,尝试运行这段代码https://developers.google.com/youtube/v3/code_samples/python#upload_a_video 修复了过时的打印调用,现在它给了我 SyntaxError: invalid syntax error
def resumable_upload(insert_request):
response = None
error = None
retry = 0
while response is None:
try:
print ("Uploading file...")
status, response = insert_request.next_chunk()
if 'id' in response:
print ("Video id '%s' was successfully uploaded." % (response['id']))
else:
exit("The upload failed with an unexpected response: %s" % response)
except HttpError, e: //error here pointed at comma
if e.resp.status in RETRIABLE_STATUS_CODES:
error = "A retriable HTTP error %d occurred:\n%s" % (e.resp.status,
e.content)
else:
raise
except RETRIABLE_EXCEPTIONS, e:
error = "A retriable error occurred: %s" % e
if error is not None:
print error
retry += 1
if retry > MAX_RETRIES:
exit("No longer attempting to retry.")
max_sleep = 2 ** retry
sleep_seconds = random.random() * max_sleep
print ("Sleeping %f seconds and then retrying..." % (sleep_seconds)
time.sleep(sleep_seconds)
我是一个完整的 python 新手,用谷歌搜索可能是因为我错过了“尝试”,但它就在那里。
因为这个YouTube API v3 upload speeds尝试python
这个错误会不会是因为我的版本比库支持的更新? https://developers.google.com/api-client-library/python/start/installation?authuser=1
【问题讨论】:
标签: python youtube google-api youtube-api syntax-error