【问题标题】:Extract the value 505 from total , the file fails to load as a json file [duplicate]从 total 中提取值 505 ,文件无法加载为 json 文件 [重复]
【发布时间】:2020-11-02 07:22:35
【问题描述】:

我的文件保存为 json ,它不会在 .我不介意您是否要将其转换为文本

{
  "startAt": 0,
  "maxResults": 0,
  "total": 505,
  "issues": [
    
  ]
}

我想要做的就是提取数字 505,它总是在总数之后:

import pandas as pd 
import json 


l=pd.read_json(r'C:\Users\ab006qj.D_ABSA\Desktop\JIRA\Number of Fields.json')

print(l['total'])

its returns 
Series([], Name: total, dtype: int64)

【问题讨论】:

  • 我们不会为您编写代码,您需要发布您的代码,我们会尽力解决您的错误
  • 这个问题不符合stackoverflow的标准。你不能要求别人为你写代码。你试过什么,什么不起作用?您的研究工作是什么?
  • 你知道它的json,你正在使用python,你想从中解析出一些数据。在搜索栏中输入parse json in python 有多难?
  • 对不起我的第一个关于堆栈溢出的问题,我添加了我的代码

标签: python json pandas


【解决方案1】:
import pandas as pd 
import json 


#l=pd.read_json(r'C:\Users\ab006qj.D_ABSA\Desktop\JIRA\Number of Fields.json')
file_name = r'C:\Users\ab006qj.D_ABSA\Desktop\JIRA\Number of Fields.json'
with open(file_name, 'r') as f:
    document =  json.loads(f.read())

print(document['total'])

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-06
    • 1970-01-01
    • 1970-01-01
    • 2017-01-06
    • 2012-01-09
    • 2016-04-14
    • 1970-01-01
    • 2020-09-20
    相关资源
    最近更新 更多