写一个类读取以下配置{ "_id":"123131", "sid": "31313ddd", "appid":"dfafafafasdfa", "account_id":"gasfafa", "app_code": "appcode", "app_name": "新的应用", "app_status": 0, "flag": 0, "create_time": "2022-10-22 12:00:22", "update_time": "2022-10-22 12:00:22" }
时间: 2023-02-06 22:30:02 浏览: 86
这是一个 Python 类,可以用来读取上述配置:
```
class Config:
def __init__(self, config_dict):
self._id = config_dict["_id"]
self.sid = config_dict["sid"]
self.appid = config_dict["appid"]
self.account_id = config_dict["account_id"]
self.app_code = config_dict["app_code"]
self.app_name = config_dict["app_name"]
self.app_status = config_dict["app_status"]
self.flag = config_dict["flag"]
self.create_time = config_dict["create_time"]
self.update_time = config_dict["update_time"]
config = Config({ "_id":"123131", "sid": "31313ddd", "appid":"dfafafafasdfa", "account_id":"gasfafa", "app_code": "appcode", "app_name": "新的应用", "app_status": 0, "flag": 0, "create_time": "2022-10-22 12:00:22", "update_time": "2022-10-22 12:00:22" })
```
这样,你就可以通过 `config._id`、`config.sid` 等属性来访问配置中的各个字段了。
阅读全文