|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
class Ticket:
price1=100
price2=120
def Values(self):
self.x=input('成人个数?')
self.y=input('儿童个数?')
if input('平日票价或者周末票价')=='平日票价':
return Ticket.price1*self.x+(Ticket.price1*self.y)/2
else:
return Ticket.price2*self.x+(Ticket.price2*self.y)/2
>>> t=Ticket()
>>> t.Values()
成人个数?2
儿童个数?1
平日票价或者周末票价平日票价
Traceback (most recent call last):
File "<pyshell#4>", line 1, in <module>
t.Values()
File "D:\python3.5.1\test.py", line 8, in Values
return Ticket.price1*self.x+(Ticket.price1*self.y)/2
TypeError: unsupported operand type(s) for /: 'str' and 'int'
错误提示不太明白 |
|