建议使用@dataclass类装饰器来修饰各种Setting类或者Variables类 #124
Unanswered
AresConnor
asked this question in
功能建议
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
原因如下:
使用@DataClass可以实现非常轻松的类的序列化
例如:
@DataClass
class Setting:
A:int
B:str
C:list
S={
![Uploading Image_1695280808863.png…]()
'A':114,
'B':'514',
'C':[1,9,1,9,8,1,0]
}
setting = Setting(**S)
,
如此 可以很方便的实现从json到类的序列化setting = Setting(**S),并且不需要为类写构造方法
Beta Was this translation helpful? Give feedback.
All reactions