Python的__init__和self是作什麼的? - What __init__ and self do on Python?

問題:

I'm learning the Python programming language and I've came across something I don't fully understand. 我正在學習Python編程語言,遇到了一些我不太瞭解的東西。 編程

In a method like: 用相似的方法: 編程語言

def method(self, blah):
    def __init__(?):
        ....
    ....

What does self do? self作什麼的? What is it meant to be? 這是什麼意思? Is it mandatory? 它是強制性的嗎? 學習

What does the __init__ method do? __init__方法有什麼做用? Why is it necessary? 爲何有必要? (etc.) (等等。) spa

I think they might be OOP constructs, but I don't know very much. 我認爲它們多是OOP構造,但我不太瞭解。 .net


解決方案:

參考一: https://stackoom.com/question/2cbz/Python的-init-和self是作什麼的
參考二: https://oldbug.net/q/2cbz/What-init-and-self-do-on-Python
相關文章
相關標籤/搜索