这是我的代码
new_key= ndb.Key(urlsafe = request.user_key)
这是用 python3 ndb 编写的 这将返回我们的密钥,我们在 urlsafe 中进行更改
key = new_key.urlsafe()
key.decode(encoding="utf-8")
但这不是返回给我们与 python2 密钥不匹配的新密钥
现在谷歌应用程序引擎已经改变而不是运动python2,但他们给了我们这个方法
to_old_key
但这不起作用
https://googleapis.dev/python/python-ndb/latest/key.html https://googleapis.dev/python/python-ndb/latest/_modules/google/cloud/ndb/key.html#Key.to_old_key
我们如何使用这个
加薪: NotImplementedError:总是。
因此,如果您使用的是云ndb,该方法总是会引发错误。该文档将您指向 from_old_key,了解其不受支持的原因。
old_key 应该是 google.appengine.ext.db.Key(其中 是 google.appengine.api.datastore_types.Key 的别名)。
但是,google.appengine.ext.db 模块是旧版模块的一部分 Google App Engine 运行时,一般不可用。