【问题标题】:SyntaxError when using except in Python [duplicate]在 Python 中使用 except 时出现 SyntaxError [重复]
【发布时间】:2015-09-10 19:59:39
【问题描述】:

我在下面的代码中由于某种原因在except httplib.IncompleteRead, e: 行中收到错误SyntaxError: invalid syntax。它的Python 3.4

import httplib
import xlrd
import urllib

try:
    url = 'http://www.bankofcanada.ca/stats/results/xls'

#In case of http.client.IncompleteRead Error
except httplib.IncompleteRead, e:
    spot_curve = e.partial
    short_end_spot_curve = e.partial 

【问题讨论】:

  • 哪个版本的 Python?应该是except httplib.IncompleteRead as e:

标签: python


【解决方案1】:

至少在 Python3 中是这样的:

 except httplib.IncompleteRead as e:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 2022-07-02
    • 1970-01-01
    • 2020-11-04
    • 2018-07-08
    相关资源
    最近更新 更多