为了账号安全,请及时绑定邮箱和手机立即绑定

在 Python 中传递 JSON 的困难

在 Python 中传递 JSON 的困难

温温酱 2021-05-30 12:36:57
我无法解析JSON. 我JSON从requests.post响应中返回的代码段:-{'result': {'parent': '', 'reason': '', 'made_sla': 'true', 'backout_plan': '', 'watch_list': '', 'upon_reject': 'cancel', 'sys_updated_on': '2018-08-22 11:16:09', 'type': 'Comprehensive', 'conflict_status': 'Not Run', 'approval_history': '', 'number': 'CHG0030006', 'test_plan': '', 'cab_delegate': '', 'sys_updated_by': 'admin', 'opened_by': {'link': 'https://dev65345.service-now.com/api/now/table/sys_user/6816f79cc0a8016401c5a33be04be441', 'value': '6816f79cc0a8016401c5a33be04be441'}, 'user_input': '', 'requested_by_date': '', 'sys_created_on': '2018-08-22 11:16:09', 'sys_domain': {'link': 'https://dev65345.service-now.com/api/now/table/sys_user_group/global', 'value': 'global'}, 'state': '-5', 'sys_created_by': 'admin', 'knowledge': 'false', 'order': '', 'phase': 'requested', 'closed_at': '', 'cmdb_ci': '', 'delivery_plan': '', 'impact': '3', 'active': 'true', 'review_comments': '', 'work_notes_list': '', 'business_service': '', 我在网上搜索。它显示为单引号,它没有解析。因此,我尝试将单引号转换为双引号。with open ('output.json','r') as handle:  handle=open('output.json')str="123"str=handle.stringify() #also with .str()str = str.replace("\'", "\"")jsonobj=json.load(json.dumps(handle))但是它向我展示了No attribute stringify or str它是一个json对象,并且这些都是字符串对象函数。那么,请您帮我看看json在文件中用单引号解析对象的正确方法是什么。
查看完整描述

2 回答

  • 2 回答
  • 0 关注
  • 171 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号