类里函数可以调用__init__函数吗
时间: 2023-12-03 11:02:04 浏览: 75
回答: 类里的函数可以调用__init__函数。__init__方法是类的构造函数,当创建类的实例时会自动调用该方法进行初始化。在类的其他函数中,可以通过实例对象来调用__init__方法,以初始化实例的属性。这样可以确保在调用其他函数之前,实例的属性已经被正确初始化。\[1\]\[2\]
#### 引用[.reference_title]
- *1* [python - 在__init__中调用类函数](https://blog.csdn.net/weixin_39818727/article/details/110046934)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [Python类的构造函数__init__(self)和析构函数__del__详解](https://blog.csdn.net/weixin_39636645/article/details/110163480)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [__call__、__init__和 forward三个函数在python中的调用方法](https://blog.csdn.net/qq_37844044/article/details/113788280)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文