![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
fuyouhan
这个作者很懒,什么都没留下…
展开
-
Python获取python文件所在目录
Python获取python文件所在目录```pythonimport osfile_path_and_name = os.path.abspath(__file__)print (">>>>> 1. The file full path: os.path.abspath(__file__) path is: ", file_path_and_name)file_full_path =原创 2021-12-11 19:19:18 · 12172 阅读 · 1 评论 -
python爬取 东方财富/天天基金网 基金排行数据
"""通过chrome driver获取指定urls的数据并解析为dataframes,然后保存为excel的多个sheet1. 该代码自动下载chrome LATEST driver2. 通过该chrome自动打开网址,加载数据3. 解析数据,并保存为excel"""from selenium import webdriverfrom webdriver_manager.chrome import ChromeDriverManagerimport pandas as pdfrom b原创 2021-11-01 08:33:11 · 1503 阅读 · 0 评论 -
Python获取2021 获取全部基金信息 天天基金网 东方财富 基金排行
Python 获取全部基金信息 天天基金网 东方财富 基金排行通过URL获取基金信息,然后切割成list的list,然后转换成表def get_fund_data(): """ 获取天天基金,8千多基金排行(默认为近6个月收益率)""" header = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.原创 2021-10-03 15:44:56 · 592 阅读 · 1 评论 -
Python网抓 2021年 获取全部沪深港股ETF股票信息 东方财富
2021年 获取全部沪深港股ETF股票信息东方财富有最全(?)的股票信息,通过代码获取沪深股票, 港股股票, ETF股票信息,然后合并, 最后保存为csv文件。环境python 3.8/3.9def get_stock_data(): """ 获取沪深,港股股票和ETF数据""" hs_url = """http://30.push2.eastmoney.com/api/qt/clist/get?cb=jQuery112404691234712152057_1632486404129&原创 2021-10-03 15:38:56 · 1098 阅读 · 0 评论 -
Python文本转table-DataFrame
工作中,经常遇到需要将查询结果的文本,转换为二维表(类似Excel的表格)格式,供代码处理, 或者保存为Excel/CSV。该代码:切割文本为list的 list(行间分隔符,行内值分割符)将切割后list的list转换为一个DataFrame或者Dictionry List。然后通过pandas保存为Excel。import pandas as pddata = """Alice,1.1,3.0,1.7,5.0,2,FEOLBob,2.2,2.6,2.5,2.6,3,MEOLCathy原创 2021-03-14 11:36:06 · 1089 阅读 · 0 评论 -
如何用Python从Oracle数据库高效查询数据
如何用Python从Oracle数据库高效查询数据要点:数据类型转换OutputTypeHandler,避免Oracle LOB/CLOB等数据类型查询报错cursor.arraysize 和cursor.prefetchrows 提高查询速度,一般于查询结果的数量import cx_Oracle #cx_Oracle module is imported to provide the API for accessing the Oracle databaseimport db_config原创 2021-01-23 14:32:53 · 1439 阅读 · 1 评论 -
Python文本转换为二维表 - Txt to List List then DataFrame/List dictionary
import pandas as pdcolumns_names = ['name', 'Math_A', 'English_A', 'Math_B', 'English_B', 'Project_num', 'Sex']data = """Alice,1.1,3.0,1.7,5.0,2,FEOLBob,2.2,2.6,2.5,2.6,3,MEOLCathy,3.3,2.0,3.6,2.4,0,MEOLDany,4.4,1.7,2.4,1.3,1,FEOLElla,5.0,3.0,5.0,3.0,7,原创 2021-01-23 12:31:44 · 803 阅读 · 1 评论