正在加载图片...
The Class Statement Before we start implementing our methods,we need to talk about how to create Accounts. Idea:All bank accounts have a balance and an account holder.These are not shared across Accounts. When a class is called: 1.A new instance of that class is created. 2.The__init_method of a class is called with the new object as its first argument(named self),along with additional arguments provided in the call expression. _init_is called class Account: the constructor ··。 def __init__(self,account_holder): self.balance 0 self.holder account_holderThe Class Statement Before we start implementing our methods, we need to talk about how to create Accounts. Idea: All bank accounts have a balance and an account holder. These are not shared across Accounts. When a class is called: 1. A new instance of that class is created. 2. The __init__ method of a class is called with the new object as its first argument (named self), along with additional arguments provided in the call expression. class Account: ... def __init__(self, account_holder): self.balance = 0 self.holder = account_holder ... __init__ is called the constructor
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有