db = UnQLite('test.db')
data = db.collection('data')
print(data.fetch(0))
这张照片
{'id': b'abc', 'type': b'business', 'state': b'AZ', 'latitude': 33.3482589,
'name': b"ABC Restaurant", 'full_address': b'1835 E ABC Rd, Ste C109, Phoenix, AZ 85284',
'categories': [b'Restaurants', b'Buffets', b'Italian'],
'open': True, 'stars': 4, 'city': b'Phoenix', 'neighborhoods': [],
'__id': 0, 'review_count': 122, 'longitude': -111.9088346}
如何获取城市的“凤凰”值?
type(data.fetch(0))
打印类“dict”
我正在查看UnQlite文档,没有找到多少。请帮忙
您已经获得了dict,因此只需搜索密钥
这里
Phoenix
不是一个str
对象,而是byte
,所以如果您想将它作为字符串,可以使用decode
来转换它或者在您的情况下:
我猜到了。执行collection.fetch(0).get('city')将给出该值
相关问题 更多 >
编程相关推荐