ooooosh 发表于 2020-5-27 17:20:28

补充程序

class Person:
    def __init__(self):
      self.__weight=56
    def getweight(self):
      (            ) #返回属性“weight”的值
    def setweight(self,v):
      (            ) #设置属性“weight”的值为v的值
x=Person()
v=int(input())
x.setweight(v)
print(x.getweight())

永恒的蓝色梦想 发表于 2020-5-27 17:27:01

自己不会做?class Person:
    def __init__(self):
      self.__weight=56
    def getweight(self):
      return self.__weight
    def setweight(self,v):
      self.__weight=v
x=Person()
v=int(input())
x.setweight(v)
print(x.getweight())
页: [1]
查看完整版本: 补充程序