简体   繁体   English

Python 中的类 JSON 对象

[英]JSON-like object in Python

I'm working with quite a bit of data in Python.我正在用 Python 处理相当多的数据。 I'm currently using a lot of different arrays but I would like to use something similar to JSON format to make it easier.我目前使用了很多不同的数组,但我想使用类似于 JSON 格式的东西来使它更容易。

something like:就像是:

metrics {
  .metric_name {
    .period {
      A: 10
      B: 20
    }
  }
}

so that I could call metrics.metric_name.A or whatever instead of using a lot of different multi-dim arrays.这样我就可以调用 metrics.metric_name.A 或其他方法,而不是使用许多不同的多维数组。

Does anything like this exist in Python? Python中是否存在这样的东西? Can I use dictionaries inside of dictionaries?我可以在字典中使用字典吗?

metrics = {
  "metric_name" : {
    "period" : {
      "A": 10,
      "B": 20,
    },
  },
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM