利用python實(shí)時(shí)刷新基金估值效果(摸魚小工具)
發(fā)布日期:2022-01-03 19:52 | 文章來(lái)源:源碼中國(guó)
摸魚小工具_(dá)利用python實(shí)時(shí)刷新基金估值 效果預(yù)覽
上源碼
import requests import json import os from prettytable import PrettyTable import time fundlist = ['163817','161017','003860'] def GetFundJsonInfo(fundcode): url = "http://fundgz.1234567.com.cn/js/"+fundcode+".js" response = requests.get(url) fundDataInfo = response.text.split('({')[1] fundDataInfo = '{'+ fundDataInfo.split('})')[0] + '}' fundDataInfo = json.loads(fundDataInfo) return fundDataInfo os.system("cls") while True: table = PrettyTable(["名稱","昨日凈值","實(shí)時(shí)估值","增長(zhǎng)率"]) for fund in fundlist: myfund = GetFundJsonInfo(fund) table.add_row([myfund['name'],myfund['dwjz'],myfund['gsz'],myfund['gszzl']]) print(table) time.sleep(5) os.system("cls")
說(shuō)明
- prettytable 通過(guò)表格格式化打印基金數(shù)據(jù)便于瀏覽數(shù)據(jù)
- os.system(“cls”) 用于清屏刷新
- 原始的響應(yīng)內(nèi)容
jsonpgz({"fundcode":"163817","name":"中銀轉(zhuǎn)債增強(qiáng)債券B","jzrq":"2021-09-10","dwjz":"3.1120","gsz":"3.1127","gszzl":"0.02","gztime":"2021-09-13 14:54"});
到此這篇關(guān)于利用python實(shí)時(shí)刷新基金估值(摸魚小工具)的文章就介紹到這了,更多相關(guān)python基金估值內(nèi)容請(qǐng)搜索本站以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持本站!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
相關(guān)文章