上班時間透過瀏覽器打開股票網站怕會被別人看到,沒關係,試試在命令列下執行程式碼看數據就行了。
輸入sh,就可以查看到上證指數
輸入sz,就可以查看深圳指數
輸入cyb,就可以查看創業板指數
其他的股票代碼可以自己自定義,加入到字典中就行了
python版本2.7 .3
#!/usr/bin/env python # -*- coding: utf-8 -*- import urllib2 import re import datetime def getStockInfo(url): """根据url获取信息""" stockList = [] request = urllib2.Request(url) response = urllib2.urlopen(request) stockStr = response.read() stockList = stockStr.split(',') return stockList def printStock(List): """打印相关信息""" print '***********price*****************' + List[1] print '***********float_price***********' + List[2] print '***********float_perct***********' + List[3] + '%' print '***********succ_unit*************' + List[4]+' shou' print '***********succ_price************' + List[5] def getUrlByCode(code): """根据代码获取详细的url""" url = '' stockCode = '' if code == 'sh': url = 'http://hq.sinajs.cn/list=s_sh000001' elif code == 'sz': url = 'http://hq.sinajs.cn/list=s_sz399001' elif code == 'cyb': url = 'http://hq.sinajs.cn/list=s_sz399006' else: pattern = re.compile(r'^60*') match = pattern.match(code) if match: stockCode = 'sh'+ code else: stockCode = 'sz' + code url = 'http://hq.sinajs.cn/list=s_'+stockCode return url #输入stock代码输出对应的价格信息 #code = raw_input('code: ') codeDict = { 'sh' : 'shang hai zq', 'sz' : 'shen zheng zq', 'cyb' : 'chang ye ban', '601788' : 'guang da zheng quan', '000651' : 'ge li dian qi', } #http://hq.sinajs.cn/list=s_sh000001 (上海大盘查询) #http://hq.sinajs.cn/list=s_sz399001 (深圳大盘查询) count = 0; while (count<=100):#循环100次后再退出 # 循环字典 for key in codeDict: print key + '--'+codeDict[key] code = raw_input('please select a code: ') now_time = datetime.datetime.now() #打印该code的信息 url = getUrlByCode(code) stockInfo = getStockInfo(url) #print stockInfo printStock(stockInfo) end_time = datetime.datetime.now() costTime = (end_time - now_time).seconds print '总共花费时间'+str(costTime)+'秒' count +=1

ForhandlinglargedatasetsinPython,useNumPyarraysforbetterperformance.1)NumPyarraysarememory-efficientandfasterfornumericaloperations.2)Avoidunnecessarytypeconversions.3)Leveragevectorizationforreducedtimecomplexity.4)Managememoryusagewithefficientdata

Inpython,ListSusedynamicMemoryAllocationWithOver-Asalose,而alenumpyArraySallaySallocateFixedMemory.1)listssallocatemoremoremoremorythanneededinentientary上,respizeTized.2)numpyarsallaysallaysallocateAllocateAllocateAlcocateExactMemoryForements,OfferingPrediCtableSageButlessemageButlesseflextlessibility。

Inpython,YouCansspecthedatatAtatatPeyFelemereModeRernSpant.1)Usenpynernrump.1)Usenpynyp.dloatp.dloatp.ploatm64,formor professisconsiscontrolatatypes。

NumPyisessentialfornumericalcomputinginPythonduetoitsspeed,memoryefficiency,andcomprehensivemathematicalfunctions.1)It'sfastbecauseitperformsoperationsinC.2)NumPyarraysaremorememory-efficientthanPythonlists.3)Itoffersawiderangeofmathematicaloperation

Contiguousmemoryallocationiscrucialforarraysbecauseitallowsforefficientandfastelementaccess.1)Itenablesconstanttimeaccess,O(1),duetodirectaddresscalculation.2)Itimprovescacheefficiencybyallowingmultipleelementfetchespercacheline.3)Itsimplifiesmemorym

SlicingaPythonlistisdoneusingthesyntaxlist[start:stop:step].Here'showitworks:1)Startistheindexofthefirstelementtoinclude.2)Stopistheindexofthefirstelementtoexclude.3)Stepistheincrementbetweenelements.It'susefulforextractingportionsoflistsandcanuseneg

numpyallowsforvariousoperationsonArrays:1)basicarithmeticlikeaddition,減法,乘法和division; 2)evationAperationssuchasmatrixmultiplication; 3)element-wiseOperations wiseOperationswithOutexpliitloops; 4)

Arresinpython,尤其是Throughnumpyandpandas,weessentialFordataAnalysis,offeringSpeedAndeffied.1)NumpyArseNable efflaysenable efficefliceHandlingAtaSetSetSetSetSetSetSetSetSetSetSetsetSetSetSetSetsopplexoperationslikemovingaverages.2)


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 Linux新版
SublimeText3 Linux最新版

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

Dreamweaver CS6
視覺化網頁開發工具