问题描述
- 请问如何数据放在leancloud里面如何查询?
-
我数据存在leancloud里面,要用python做个查询,比如我知道一个人员的名字,想查询他的年龄,我看了leancloud的官方文档的查询:1:
from leancloud import Object from leancloud import QueryGameScore = Object.extend('GameScore')query = Query(GameScore) query.equal_to('playerName', 'Dan Stemkoski') gameScores = query.first() print gameScores
输出的是一个
<leancloud.object_.GameScore object at 0xb75072cc>,
不知道如何读取这个数据的内容
2:然后我看有个select
GameScore = Object.extend('GameScore') query = Query(GameScore) query.select('score', 'playerName')
仍然返回
<leancloud.object_.GameScore object at 0xb75072cc>
3 然后试了一下fetch(),返回的是None,我确定表里是有数据的。
GameScore = Object.extend('GameScore') query = Query(GameScore) query.select('score', 'playerName') print query.first().fetch()
请问该如何写代码,能像select age from people where name = ‘Jim’一样返回一个字段信息?
解决方案
from leancloud import Object
from leancloud import
QueryGameScore = Object.extend('GameScore')
query = Query(GameScore)
query.equal_to('playerName', 'Dan Stemkoski')
gameScores = query.first()
print gameScores.get('score')
时间: 2024-09-07 16:23:36