我想创建一个具有构造函数,带有get和set方法并使用属性的类myCalc。我了解get和set方法,但是在将所有部分组合在一起时遇到了麻烦,因此它可以执行我想要的操作。我到目前为止所拥有的是:
class myCalc(object):
def __init__(self):
self._ =name
def (self):
"""Get the answer doubled."""
return self._plus
def (self):
"""Get the answer squared."""
return self._times
Run Code Online (Sandbox Code Playgroud)
我想让程序响应的对象具有将对象中的数字加倍和平方的属性。任何的意见都将会有帮助。