|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
这个其实是38讲动动手 我知道我写的不对 就当我这是随意设置了三个变量进行运算吧。
运行这个代码的时候报错 应该是说最后print里的不是数字 而是字符串 在哪个地方能把self.daypay , self.child改为数字形式呢
class playgurand():
daypay = 100
weekends = 120
child = 50
def pays(self,daypay,child):
self.daypay = daypay
self.child = child
def end(self):
print('%f' % (self.daypay * 2 + self.child))
>>> a = playgurand()
>>> a.pays('daypay','child')
>>> a.end()
Traceback (most recent call last):
File "<pyshell#99>", line 1, in <module>
a.end()
File "<pyshell#96>", line 10, in end
print('%f' % (self.daypay * 2 + self.child))
TypeError: must be real number, not str |
|