|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
如题
- >>> class Rectangle:
- length=5.00
- width=4.00
- def getRect():
- print('这个矩形的长是'+length+',宽是:'+width)
- def setRect():
- print('请输入这个矩形的长和宽——')
- length=input('长:')
- width=input('宽:')
-
- >>> a=Rectangle()
- >>> a.getRect
- <bound method Rectangle.getRect of <__main__.Rectangle object at 0x004DAC90>>
- >>>
复制代码
为什么结果没有打印出长和宽
而是给出地址
本帖最后由 新手·ing 于 2017-8-15 18:17 编辑
- class Rectangle:
- length='5.00'
- width='4.00'
- def getRect(self):
- print('这个矩形的长是'+self.length+',宽是:'+self.width)
- def setRect(self):
- print('请输入这个矩形的长和宽——')
- self.length=input('长:')
- self.width=input('宽:')
复制代码
|
|