获取实体';不同格式的属性值(GAE Python)
在谷歌应用程序引擎中获取实体';不同格式的属性值(GAE Python),python,google-app-engine,referenceproperty,Python,Google App Engine,Referenceproperty,在谷歌应用程序引擎中 当我试图通过ReferenceProperty元素获取属性值时 它以不同的格式返回引用的实体值,如: 实际存储值“名称”:“demoname” 当我得到并打印/写入:u'demoname 是否有任何函数或方法以正确的字符串格式获取值。 代码: 人员模型具有名称属性: o_model=model() o_model.ref=personmodel reference#db.ReferenceProperty(person) 现在我得到模型实体对象: sro.write(mo
当我试图通过ReferenceProperty元素获取属性值时
它以不同的格式返回引用的实体值,如:
实际存储值“名称”:“demoname”
当我得到并打印/写入:u'demoname
是否有任何函数或方法以正确的字符串格式获取值。
代码:
人员模型具有名称属性:
o_model=model()
o_model.ref=personmodel reference#db.ReferenceProperty(person)
现在我得到模型实体对象:
sro.write(modelobject.ref.name)
输出:u'namevalue
通缉:namevalue如果
modelobject.ref.name
是一个,那么它就是一个”
u'
看起来像unicode
对象的名称:
>>> s = u"Unicode String."
>>> print s
Unicode String.
>>> print repr(s)
u'Unicode String.'
可能是
sro.write()
调用repr()
,或者您正在将Unicode字符串的repr()
存储在数据存储中?同样的事情尝试使用实体对象,我得到了完美的结果。但当尝试使用referenceProperty时,它将以这种unicode格式返回。