super().__init__(**kwargs)

最近补充一下python知识,关于super().init(**kwargs)属于在class中常用的调用父类方法:
`class Child(father_class):

name: str = "Stitch"
profile: str = "Tutorial Assistant"
goal: str = "Generate tutorial documents"
constraints: str = "Strictly follow Markdown's syntax, with neat and standardized layout"

topic: str = ""
main_title: str = ""
total_content: str = ""

def __init__(self, **kwargs):
    super().__init__(**kwargs)`

其中super()方法相当于对父类属性的继承,而**kwargs相当于传递把子类的这些值进行赋值
kwargs是一种将任意数量的关键字参数传递给函数的方式。在构造函数中使用kwargs可以让你从子类向父类传递参数,而无需显式列出所有参数

posted @ 2024-06-21 16:56  Kevincoding  阅读(156)  评论(0)    收藏  举报