如何在python中获取json的数据

如何在python中获取json的数据,python,json,netbeans,Python,Json,Netbeans,我有这段代码,在这段代码中,我从url(ajax)获取一个json对象,我需要获取内部数据,这是我的代码: url = URL_BASE9 req = requests.get(url) statusCode = req.status_code if statusCode == 200: html = BeautifulSoup(req.text, "html.parser") #print(html) 这是我的结果 `{'FiltroFechaInicio': '/Date(-6213

我有这段代码,在这段代码中,我从url(ajax)获取一个json对象,我需要获取内部数据,这是我的代码:

url = URL_BASE9


req = requests.get(url)
statusCode = req.status_code
if statusCode == 200:

html = BeautifulSoup(req.text, "html.parser")
#print(html)
这是我的结果

`{'FiltroFechaInicio': '/Date(-62135586000000)/', 'Pagina': 1, 'ListHechos': 
 [{'contenido': '<div class="ExternalClass3DB02CFE22F84F3F998EBEA913E5A79B">
 <div><a 
 href="/Noticiascibe/hechos%20esenciales/NAVIERA/hes_2017060105740.pdf">
 hes_2017
 060105740.pdf</a></div></div>', 'Activo': None, 'FechaString': '15-06-
 2017', 
 'TipoAdjunto': None, 'UrlAdjunto': 
 '/Noticiascibe/hechos%20esenciales/NAVIERA/hes_2017060105740.pdf', 
 'Descripcion': None, 'UrlImagen': None, 'ClaseIconoAdjunto': 
 'iconoDescargaPDF', 'Fecha': '/Date(1497566727000)/'}`
“{'filterofechanicio':'/Date(-62135586000000)/”,'Pagina':1,'ListHechos':
[{'contenido':'
“,“Activo”:无,“FechaString”:“15-06”-
2017', 
“TipoAdjunto”:无,“urlajunto”:
“/noticeAscibe/hechos%20esenciales/NAVIERA/hes_2017060105740.pdf”,
'description':无,'UrlImagen':无,'ClaseIconoAdjunto':
“iconoDescargaPDF”,“Fecha:”/Date(1497566727000)/”}`

如何获取数据内容,谢谢,祝您愉快

这与dictionary相同,每个键都有一个键和值

  my_dict = {
    'key1': 'value1',
    'key2': 'value2',
    'key3': 'value3'
    }
my_dict['key1']

# Out: 'value1'

没有“JSON对象”这样的东西,您指的是JSON字符串

要将JSON字符串转换为对象,可以使用JSON模块()中的
JSON.loads(JSON_str)

例如:

import json
json_str = '{ "FiltroFechaInicio": "/Date(-62135586000000)/" }'
my_obj = json.loads( json_str )
顺便说一下,您发布的JSON字符串无效且不完整。
有效的JSON必须包含双引号中的键和字符串。

可能重复抱歉,我的英语不太好,我需要提取JSON的数据字符串,因为提取数据后,我可以将数据插入数据库中