Closed ccdjh closed 11 years ago
kv.get_by_prefix的返回值是一个generator,如果需要转换成list,可以这样:
[i for i in kv.get_by_prefix('t')]
getkeys_by_prefix 和 get_by_prefix 都出问题。你测试一下。
>>> import sae.kvdb
>>> kv = sae.kvdb.KVClient()
>>> result = kv.get_by_prefix('k')
>>> [i for i in kv.get_by_prefix('k', limit=5)]
[('k', 123443), ('k0', '<value>'), ('k1', 1), ('k10', '<value>'), ('k100', '<value>')]
没有问题阿。
囧,因为之前kv.get_by_prefix('k')是直接返回一个完整的list的。是我的操作问题,还是你们改了?
class T(tornado.web.RequestHandler): def get(self): kv = sae.kvdb.KVClient() c = kv.get_by_prefix('t') self.write(str(c))
返回结果是 :
《generator object _get_by_prefix at 0x14dc500》