|
|

楼主 |
发表于 2019-6-9 10:49:55
|
显示全部楼层
class Stock:
def __init__(symbol,name,preClosingPrice,curPrice):
self.symbol=symbol
self.name=name
self.preClosingPrice=preClosingPrice
self.curPrice=curPrice
def getsymbol(symbol):
return self.symbol
def getname(name):
return self.name
def getname(preClosingPrice):
return self.preClosingPrice
def getname(curPrice):
return self.curPrice
def getChangePercent(self):
a=((self.curPrice-self.preClosingPrice)/self.preClosingPrice)*100
return a
mycla = Stock(10001,"平头哥芯片",62.8,70.32)
print(mycla.getname())
print(mycla.getpreClosingPrice())
print(mycla.getcurPrice())
print("{:.2%}".format(mycla.getChangePercent))
写好了但是运行起来是错误的?
mycla = Stock(10001,"平头哥芯片",62.8,70.32)
TypeError: __init__() takes 4 positional arguments but 5 were given
该怎么办呢?
|
|