• 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()

  • 相关阅读:
    单片机 C语音开发 sbit使用方法··
    android笔记JSON数据解析
    android软键盘挡住输入框问题解决方法
    android学习
    View.setTag()与View.getTag()的作用
    【Android学习专题】数据存储篇:SharedPreferences/Files/SDCard
    android完美退出程序
    Looper.prepare()
    各种Adapter的用法
    android 界面布局 很好的一篇总结 【转】
  • 原文地址:https://www.cnblogs.com/Death/p/1992266.html
Copyright © 2020-2023  润新知