报:format() takes at most 2 arguments 在网上找,看到有人解释,按这位博主方法更改,果然有效 之前是按python2创建类,Person(object)如上类名Person括号后加了object,python3中将object去掉即可
class Person(): def __init__(self,name,age,gender): self.name=name self.age=age self.gender=gender def kanchai(self): print("{0},{1},{2},喜欢上山去砍柴".format(self.name,self.age,self.gender))Per=Person(u'小明','10岁','男')Per.kanchai()