|
|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
- class Money():
- def __int__(self,weekend=False,child=False):
- self.exp = 100
- if weekend:
- self.inc = 1.2
- else:
- self.inc = 1
- if child:
- self.discount = 0.5
- else:
- self.discount = 1
-
- def clac(self,num):
- return (self.exp*self.int*self.discount*num)
- aults = Money()
- child = Money(child=True)
- print('2个成人+1个小孩的平日票价为:%.2f' % (aults.clac(2)+child.clac(1)))
复制代码
以下是报错的内容:
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
============= RESTART: C:/Users/fengx/Desktop/python/30~60/2.py =============
Traceback (most recent call last):
File "C:/Users/fengx/Desktop/python/30~60/2.py", line 19, in <module>
child = Money(child=True)
TypeError: object() takes no parameters
>>>
def __init__(self,weekend=False,child=False):
|
|