为什么Python,因为Python简单,用更少的代码实现更多的功能;
为什么要实现股票行情接收,纯属学习Python,如果能为我炒股的朋友提供帮助就更好了;
为什么是V001,学习python过程中,不可能一次将该功能做完,想到什么功能就做什么,慢慢更新。
背景:股票行情源使用sina的web行情源:"http://hq.sinajs.cn/list=sh000001,sz000002" (其中股票代码部分可以改变), 详细信息参考:http://blog.sina.com.cn/s/blog_540f22560100ba2k.html
首先,定义一个股票基本信息的数据结构:
class QuoteData:
def __init__(self):
self.stockid = ''
self.stockName = ''
self.lastPrice = ''
self.preClose = ''
self.openPrice = ''
self.lowPrice = ''
self.highPrice = ''
self.avgPrice = ''
def Print(self):
print "%s(%s) %s %s %s %s %s %s" % (self.stockName, s