Python大数据编程4数据分析3数据描述1数据收集2数据整理大数据处理过程2便捷数据获取Python大数据编程用Python获取数据本地数据如何获取?文件的打开,读写和关闭• 文件打开• 读文件写文件• 文件关闭4用Python获取数据网络数据如何获取?抓取网页,解析网页内容urlliburllib2httplib•://finance./q/cp?s=%ponen利用urllib库获取yahoo财经数据File#Filename:=('http://finance./q/cp?s=%ponents').read()dStr=('GBK')#()返回bytes对象而非str,语句功能是将dBytes转换成Strm=('<tr><tdclass="yfnc_tabledata1"><b><ahref=".*?">(.*?)</a></b></td><tdclass="yfnc_tabledata1">(.*?)</td>.*?<b>(.*?)</b>.*?</tr>',dStr)ifm:printmprint'\n'printlen(m)else:print'notmatch'数据形式• 包含多个字符串(dji)'AXP','pany','''BA','pany','''CAT','CaterpillarInc.','''CSCO','CiscoSystems,Inc.','''CVX','ChevronCorporation',''– …便捷网络数据是否能够简单方便并且快速的方式获得雅虎财经上各上市公司股票的历史数据?File#Filename:=()start=(-1,,)quotes=quotes_historical_yahoo_ochl('AXP',start,today)df=(quotes)printdf函数目前更新为quotes_historical_yahoo_ochl便捷网络数据quotes的内容日期收盘价开盘价最高价最低价成交量
Python大数据编程课件 来自淘豆网www.taodocs.com转载请标明出处.