Python 获取股票数据 弹出框 自动关闭 测试代码

来源:互联网 发布:冰岛旅游 知乎 编辑:程序博客网 时间:2024/06/06 12:56
import osimport timeimport threadingimport tushare as tsfrom Tkinter import *from multiprocessing import Process#name="ss"def func():    print 'exit'    os._exit(0)    print 'func2'def creatfram(name):    root = Tk()    w = Label(root, text=name)    w.pack()    root.mainloop()    print 'creatfram'def doubler(number):    """    A doubling function that can be used by a process    """    df = ts.get_realtime_quotes('603999')  # Single stock symbol    print df[['code', 'name', 'price', 'time']]    name = (df['name']) + (df['price'])    print name    if float(df['price']) > 5:        timer = threading.Timer(5, func)        timer.start()        creatfram(name)        result = number * 2        proc = os.getpid()        print('{0} doubled to {1} by process id: {2}'.format(            number, result, proc))if __name__ == '__main__':    numbers = [5, 10, 15, 20, 25]    procs = []    while True:        #time.sleep(1)        for index, number in enumerate(numbers):            proc = Process(target=doubler, args=(number,))            procs.append(proc)            proc.start()        for proc in procs:            proc.join()
0 0
原创粉丝点击