缺少一个必需的位置参数
class Admin():def __init__(self,name):
self.name = name
def privilegs(self):
L = ['can add','post shit','can ban','can delete']
def show_privilegs(self,L):
print(self.name+str(L))
m=Admin('he')
m.show_privilegs()
File "D:/PycharmProjects/book/9/9-1.py", line 28, in <module>
m.show_privilegs()
TypeError: show_privilegs() missing 1 required positional argument: 'L'
你得传入一个参数
class Admin():
def __init__(self,name):
self.name = name
def privilegs(self):
L = ['can add','post shit','can ban','can delete']
def show_privilegs(self,L):
print(self.name+str(L))
m=Admin('he')
m.show_privilegs('123')
页:
[1]