【问题】类定义中__init__(self)与add(self.
2019-12-29 本文已影响0人
思想践行

def __init__(self):
self.bots = []
self.bots是实例变量(这里是参数组)
def add(self,bot):
self.bots.append(bot)
bot是类方法的输入参数
我的问题:
为什么
__init__()
中的参数bots
不用写,
add()
中的参数bot
一定要写出来?