我在使用Uber Python API时遇到问题

2024-04-26 07:03:00 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python编写代码,使用2.6版本,使用Uber API,当我试图导入库uber_rides.auth时,它会抛出以下错误:

Traceback (most recent call last):
  File "C:\Inetpub\vhosts\underdevelopment.biz\httpdocs\web\webtemp3\uber\socket.py", line 4, in <module>    
    from uber_rides.auth import AuthorizationCodeGrant
  File "C:\Inetpub\vhosts\underdevelopment.biz\httpdocs\web\webtemp3\uber\uber_rides\auth.py", line 133
    query_params = [qp: query_params[qp][0] for qp in query_params]
                      ^
SyntaxError: invalid syntax

我的脚本的原始代码是:

^{pr2}$

好像是图书馆的错误,但我还找不到。在


Tags: 代码authweb错误paramsqueryfilerides
1条回答
网友
1楼 · 发布于 2024-04-26 07:03:00

是的,这是无效的Python语法。但是,现在还不清楚你是如何得到那个文件的。在

有人或是什么东西修改了那个文件。这不是original source code as distributed by Uber,该行使用正确的语法来理解字典:

query_params = {qp: query_params[qp][0] for qp in query_params}

上游工程没有安装错误。在

请注意,上述语法仅在Python2.7及更高版本中可用。您可以尝试用一个生成器表达式来替换它dict()调用,请参见Alternative to dict comprehension prior to Python 2.7

^{pr2}$

考虑到代码中可能存在其他问题,升级到python2.7可能是更好的选择。在

相关问题 更多 >