Skip to content

Instantly share code, notes, and snippets.

@fddn
Created August 31, 2020 12:56
Show Gist options
  • Save fddn/4beed74d1a331e600510681e7ba90d9a to your computer and use it in GitHub Desktop.
Save fddn/4beed74d1a331e600510681e7ba90d9a to your computer and use it in GitHub Desktop.

Revisions

  1. fddn created this gist Aug 31, 2020.
    10 changes: 10 additions & 0 deletions data.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    {
    "data1": [
    "data11",
    "data12"
    ],
    "data2": [
    "data21",
    "data22"
    ]
    }
    14 changes: 14 additions & 0 deletions data.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    import json


    class Data(object):
    def __init__(self):
    with open('data.json') as json_file:
    self.data = json.load(json_file)
    self.__dict__ = dict(self.data)


    if __name__ == "__main__":
    data = Data()
    print(data.data1)
    print(data.data2)