凤眼的保 凤眼的保
class Stock():
def __init__(self):
self.__no = ""
self.__name = ""
self.previousClosingPrice = 0
self.currentPrice = 0
def creatStock(self,stockInfo):
self.__no = stockInfo[0]
self.__name = stockInfo[1]
self.previousClosingPrice = stockInfo[2]
self.currentPrice = stockInfo[3]
def getStockName(self):
return(self.__name)

def getStockNo(self):
return(self.__no)

def setPreviousClosingPrice(self,price):
self.previousClosingPrice = price

def getPreviousClosingPrice(self):
return(self.previousClosingPrice)

def setCurrentPrice(self,price):
self.currentPrice = price

def getCurrentPrice(self):
return(self.currentPrice)
def getChangePercent(self):
return((self.currentPrice - self.previousClosingPrice)/self.currentPrice)

stock = Stock()
stock.creatStock(["601318","中国平安",63.21,64.39])
print(stock.getStockNo())
print(stock.getStockName())
print(stock.getCurrentPrice())
print(stock.getPreviousClosingPrice())
2019-12-09 14:06:34
1,641次浏览
1次回答
您可以添加微信进行咨询
微信号: