python - Appengine 中使用什么版本/风格的 Python?

标签 python google-app-engine

我第二次想知道使用哪个版本的 Python Google Appengine Python 2.7 运行时。

这是自 2.6 以来绝对有效的 Python,我希望 query_string 之后是“测试”:

query_string = "(test)"
query_string = query_string.translate(None, "()")

但在 Google Appengine 上,它会导致 TypeError translate() takes exactly one argument (2 given)

上周,我们遇到了另一种奇怪的行为,一个函数 a 调用了另一个函数 b,这可能会引发 ValueError。我可以在函数 b 中捕获异常,但不能在 a 中捕获异常,因为异常的传播,后端刚刚崩溃。 不过,几个小时后,这个错误(?)被修复了。

编辑:我正在使用 Python 2.7 运行时,sys.version 返回 2.7.3(默认,2012 年 10 月 15 日,11:27:13)

应用程序.yaml:

application: test
version: 1
runtime: python27
api_version: 1
threadsafe: no

最佳答案

根据您的更新进行编辑:
这可能是也可能不是问题的根本原因,但您的 app.yaml 不正确。 threadsafe 的允许值为 truefalse。链接到文档的相应部分:https://developers.google.com/appengine/docs/python/config/appconfig


原答案:
如果您没有在 app.yaml 中指定 GAE 应为您的应用程序使用 Python 2.7 运行时,则可能发生这种情况的唯一方法。下面是an example from the excellent documentation :

application: helloworld
version: 1
#        vvvvvvvv
runtime: python27
api_version: 1
threadsafe: true

handlers:
- url: /.*
  script: helloworld.app

如果您没有为runtime 指定python27,GAE 将使用Python 2.5

关于python - Appengine 中使用什么版本/风格的 Python?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15100125/

相关文章:

python - IntEnum 返回 AttributeError : can't set attribute

python - 从数据库打印列表

python - 如何实例化具有已知系数的 Scikit-Learn 线性模型而不进行拟合

python - 如何避免 AttributeError 并在 Python 中获取未定义的值?

android - 带有 AppEngine 通信错误的 ReSTLet Android

google-app-engine - 减少数据存储读取操作

Python:链接的关键字

python - 如何在谷歌应用程序引擎中使一项任务在另一项任务完成后立即开始?

python - 使用 beautifulSoup 抓取表格 HTML

google-app-engine - 带有 Flask 的 Google 应用引擎 : Memorystore/redis produces [Errno 104] Connection reset by peer