我在SQL管理工作室中有一个空表,我想用每个句子的值填充它。该表有3列 - SentId,Word,Count。在列表中的字典中返回值,字典中的整个事物
我的句子具有这样的结构:
sentence = {‘features’: [{}, {}, {}…] , ‘id’: 1234}
- >要填写SentId值,我调用SQL“插入到表中的值(3列在这里提供3个值)”语句,输入语句[ id'],它返回1234.很简单。随着下一步我有问题。
- >要获取字值和Count列,我要进去 '的特点' 具有这种结构:
‘features’: [ {‘word’:’ hello’, ‘count’: 2}, {‘word’: ’there’, ‘count’:1}, {}, {}…]
我跑这至今:
sentence = {'features': [{'word': 'hello', 'count': 2}, {'word': 'there', 'count':1}] , 'id': 1234}
print(sentence['features'])
#out>> [{'word': 'hello', 'count': 2}, {'word': 'there', 'count': 1}]
所以我需要进入列表中的字典。 这didn`t工作:
print(sentence['features'].get("word"))
非常感谢帮助我。我是编程新手。
句子[“功能”] [0] [“字”] –
唐用-1标记我;反而帮助我。谢谢 – el347
谢谢!!!!我很快会删除我的愚蠢问题 – el347