使用 split python 从 JSON 生成不同的字符串
Generate different strings from a JSON using split python
我正在尝试检索从 firebase 中提取的 JSON 的值,JSON 是:
{"data": "01/01/2000", "destino": "JPY", "nome": "teste", "origem": "BRL", "taxa": 1.4000000000000004, "valordestino": 14.000000000000002, "valororigem": 100.0}
我想将这些值中的每一个插入到 QTableWidget 中。考虑到这一点,我想将 JSON 分解为数据库中每个值的字符串 (例如 data、destino、nome、origem、taxa,...) 基本上我想要的是:
teste[0] = 01/01/2000
teste[1] = JPY
teste[2] = teste
teste[3] = BRL
teste[4] = 1.40
teste[5] = 14.00
teste[6] = 100
我尝试在 JSON 中找到的每个 :
中使用 split
来拆分 JSON,但这没有用。
usuarios = db.child("operacoes").get()
for usuario in usuarios.each():
teste = json.dumps(usuario.val())
teste.split(':')
print(teste)
关于如何解决这个问题有什么建议吗?
usuarios = db.child("operacoes").get()
for usuario in usuarios.each():
teste = list(usuario.val().values())
print(teste)
我正在尝试检索从 firebase 中提取的 JSON 的值,JSON 是:
{"data": "01/01/2000", "destino": "JPY", "nome": "teste", "origem": "BRL", "taxa": 1.4000000000000004, "valordestino": 14.000000000000002, "valororigem": 100.0}
我想将这些值中的每一个插入到 QTableWidget 中。考虑到这一点,我想将 JSON 分解为数据库中每个值的字符串 (例如 data、destino、nome、origem、taxa,...) 基本上我想要的是:
teste[0] = 01/01/2000
teste[1] = JPY
teste[2] = teste
teste[3] = BRL
teste[4] = 1.40
teste[5] = 14.00
teste[6] = 100
我尝试在 JSON 中找到的每个 :
中使用 split
来拆分 JSON,但这没有用。
usuarios = db.child("operacoes").get()
for usuario in usuarios.each():
teste = json.dumps(usuario.val())
teste.split(':')
print(teste)
关于如何解决这个问题有什么建议吗?
usuarios = db.child("operacoes").get()
for usuario in usuarios.each():
teste = list(usuario.val().values())
print(teste)