将c sharp代码转换为python类用法



我不熟悉python,我想将下面的代码从C#转换为python


Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse)
public class StatisticsItem
{
public string name { get; set; }
public string home { get; set; }
public string away { get; set; }
public int compareCode { get; set; }
}
public class Group
{
public string groupName { get; set; }
public List<StatisticsItem> statisticsItems { get; set; }
}
public class Statistic
{
public string period { get; set; }
public List<Group> groups { get; set; }
}
public class Root
{
public List<Statistic> statistics { get; set; }
}

目的是将JSON平面文件转换为一个对象,我可以用C#来完成,但我在python 中遇到了一些困难

您需要在类中使用__dict__属性。

有关更多详细信息,请参阅文档以及以前的"堆栈溢出"答案。

最新更新