Python 2.6 数据库错误 [英] Python 2.6 DB error

查看:61
本文介绍了Python 2.6 数据库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试获取 Yahoo!BOSS 包工作正常,但是当我尝试运行示例文件时出现以下错误:

I'm trying to get the Yahoo! BOSS package working, but when I try to run the example file I get the following error:

$ python examples/ex5.py 
  File "examples/ex5.py", line 28
    tb = db.group(by=["yn$title"], key="rank", reducer=lambda d1,d2: d1+d2, as="total", table=tb, norm=text.norm)
                                                                             ^
SyntaxError: invalid syntax

此特定错误仅发生在 Python 2.6 中.当我尝试在 Python 2.5 中运行时,不会发生此错误(但会引发其他错误,因为我在 2.5 中尚未安装许多其他支持包).

This particular error only occurs in Python 2.6. When I attempt to run in Python 2.5, this error does not occur (but it throws other errors because I was haven't installed a number of other supporting packages in 2.5).

请注意,所有示例文件都在此 db.group 函数上失败,在每种情况下,克拉都突出显示为as".

Note that all the example files fail on this db.group function, with the carat highlighting "as" in each case.

是否有与 2.6 相关的更改可能导致此错误?

Is there a 2.6-related change that could be causing this error?

推荐答案

as 在 2.5 中是一个伪关键字,它在 2.6 中变成了一个成熟的关键字——这绝对是你的原因问题!

as was a pseudo-keyword in 2.5, it's become a full-fledged keyword in 2.6 -- that's definitely the cause of your problem!

至于解决方法,请尝试在通话结束时添加 **{'as': 'total'} 并删除普通的 as='total'> -- 应该可以.

As for the workaround, try adding a **{'as': 'total'} at the end of your call and remove the plain as='total' -- that should work.

这篇关于Python 2.6 数据库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆