这种格式是什么?如何在J中将其转换为json

2024-06-01 11:06:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用parallelbotsapi来进行情绪分析,在python中,api返回

{u'probabilities': {u'positive': 0.214111, u'neutral': 0.66828, u'negative': 0.11761}, u'usage': u'By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions', u'sentiment': u'neutral'}

这是unicode格式还是其他格式,如何将其转换为JSON以便在JS中使用


Tags: orapiby格式usage情绪negativeaccessing
1条回答
网友
1楼 · 发布于 2024-06-01 11:06:09

使用python json modulejson.dumps()

import json
data = {u'probabilities': {u'positive': 0.214111, u'neutral': 0.66828, u'negative': 0.11761}, u'usage': u'By accessing ParallelDots API or using information generated by ParallelDots API, you are agreeing to be bound by the ParallelDots API Terms of Use: http://www.paralleldots.com/terms-and-conditions', u'sentiment': u'neutral'}
print data
data = json.dumps(data)
print data

相关问题 更多 >