回答详情
凤眼的保
2019-12-21 00:00:00
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())
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())
最新回答
2026-10-29 18:12:00
2026-10-29 18:11:53
2026-10-29 18:11:45
2026-10-29 18:11:37
2026-10-29 18:11:28
2026-10-29 18:11:12


