python显示股票价格

最近有个朋友炒股 但又怕被人发现 于是用我刚学的python给他写了个看股票的东东

 

# coding: gbk
from  Tkinter  import  Tk,Entry,Button,mainloop
from  tkFont  import  Font 
import  urllib2
import  codecs
import  threading

def  getStock():
    codes 
=  code.get().split( ' , ' )
    allv 
=  []
    
for  c  in  codes:
        c 
=   " sh " + if  c.startswith( ' 6 ' else   " s_sz " + c
        res 
=  urllib2.urlopen( ' http://hq.sinajs.cn/list=%s ' % c).read();
        res 
=  res.replace( ' " ' , '' ).split( ' = ' )[ 1 ].split( ' , ' )
        
if  len(res)  >   1 :
            allv.append(res[
1 ])
        
else :
            allv.append(
' -.-- ' )
    result.delete(0,
' end ' )
    result.insert(0,
' , ' .join(allv))
    result.update()
    
global  IsStartTake
    
if  IsStartTake  ==  True:
        t 
=  threading.Timer( 1.0 , getStock)
        t.start()
def  run():
    
global  IsStartTake
    
if  IsStartTake  ==  False:
        t 
=  threading.Timer( 1.0 , getStock)
        t.start()
    IsStartTake 
=   not  IsStartTake
    
IsStartTake 
=  False
root 
=  Tk()
root.title(
" stock " )
ft 
=  Font(family  =  ( ' Verdana ' ), size  =   8  )  # 字体  
code  =  Entry(root, font =  ft,width = 50 )
result 
=  Entry(root, font =  ft,width = 50 )
code.pack()
result.pack()
Button(root,text
= u ' 开关 ' ,command  =  run).pack()
root.mainloop()

转载于:https://www.cnblogs.com/Death/archive/2011/03/23/1992266.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值