class Stock():
def __init__(self):
self.__symbol=""
self.__name=""
self.preClosingPrice=0
self.curPrice=0
def oneStock(self,detailContent):
self.__symbol=detailContent[0],
self.__name=detailContent[1],
self.preClosingPrice=detailContent[2],
self.curPrice=detailContent[3],
def getStockSymbol(self):
return(self.__symbol)
def getStockName(self):
return(self.__name)
def getpreClosingPrice(self):
return(self.preClosingPrice)
def setpreClosingPrice(self,price):
self.preClosingPrice = price
def getcurPrice(self):
return(self.curPrice)
def setcurPrice(self,price):
self.curPrice = price
def getChangePercent(self):
x=self.curPrice-self.preClosingPrice
y=x/self.curPrice
return(y)
astock=Stock()
astock.oneStock(["10001","平头哥芯片",62.82,70.32])
print(astock.getStockSymbol())
print(astock.getStockName())
print(astock.getCurPrice())
print(astock.getPreClosingPrice())
Python的一段代码,有没有人看看怎么老是运行不起来,好的必采纳
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
3条回答 默认 最新
- 风铃扬音 2021-11-20 11:03关注
class Stock(): def __init__(self): self.__symbol="" self.__name="" self.preClosingPrice=0 self.curPrice=0 def oneStock(self,detailContent): self.__symbol=detailContent[0], self.__name=detailContent[1], self.preClosingPrice=detailContent[2], self.curPrice=detailContent[3], def getStockSymbol(self): return(self.__symbol) def getStockName(self): return(self.__name) def getpreClosingPrice(self): return(self.preClosingPrice) def setpreClosingPrice(self,price): self.preClosingPrice = price def getcurPrice(self): return(self.curPrice) def setcurPrice(self,price): self.curPrice = price def getChangePercent(self): x=self.curPrice-self.preClosingPrice y=x/self.curPrice return(y) astock=Stock() astock.oneStock(["10001","平头哥芯片",62.82,70.32]) print(astock.getStockSymbol()) print(astock.getStockName()) # print(astock.getCurPrice()) #原 print(astock.getcurPrice()) # print(astock.getPreClosingPrice()) #原 print(astock.getpreClosingPrice()) # 定义函数不能嵌套定义, #缩进问题 #最后两行调用函数的函数名大小写有误。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
- ¥15 孟德尔随机化怎样画共定位分析图
- ¥18 模拟电路问题解答有偿速度
- ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
- ¥15 误删注册表文件致win10无法开启
- ¥15 请问在阿里云服务器中怎么利用数据库制作网站
- ¥60 ESP32怎么烧录自启动程序
- ¥50 html2canvas超出滚动条不显示
- ¥15 java业务性能问题求解(sql,业务设计相关)
- ¥15 52810 尾椎c三个a 写蓝牙地址