
python
认识柚子吗?
这个作者很懒,什么都没留下…
展开
-
python 列表从报错位置继续运行,爬虫必备
错误是0被除 a=[6,4,32,0,43,12,1,34,0,12,231,4,1,3] #列表 def q(s): #函数 try: for i in a[s:]: //给列表一个切片位置 s+=1 //跳过错误位置以防止无限循环错误 100/i //这是我故意制造的错误 print(i)原创 2020-12-17 15:55:19 · 383 阅读 · 0 评论 -
pandas 将个别带万的字符串 转换为float类型或者int类型
将个别带万的字符串 转换为float类型或者int类型 df['价格']=df['价格'].apply(lambda x: float(x.split('万')[0])*10000 if x.split('万')[-1]=='' else float(x)).astype(int)原创 2020-10-27 20:22:10 · 1770 阅读 · 2 评论 -
pandas内置函数
1.导入数据 pd.read_csv(filename):从CSV文件导入数据 pd.read_table(filename):从限定分隔符的文本文件导入数据 pd.read_excel(filename):从Excel文件导入数据 pd.read_sql(query, connection_object):从SQL表/库导入数据 pd.read_json(json_string):从JSON格式的字符串导入数据 pd.read_html(url):解析URL、字符串或者HTML文件,抽取其中的tables原创 2020-10-25 18:31:54 · 595 阅读 · 0 评论 -
selenium的基础使用与思路
selenium第三方库基础思路 打开谷歌浏览器 driver=webdriver.Chrome() 窗口最大化 driver=maximize_window() 获取切换iframe #切换到iframe 中 # driver.switch_to.frame('driver.find_element_by_(?)的对象') # driver.switch_to.frame('iframe的id') # driver.switch_to.frame('iframe的name') 我的管用手法: d原创 2020-10-09 19:52:01 · 109 阅读 · 0 评论 -
Python_输入年月日计算是今年第几天 考虑闰年二月29天,平年28天
定义函数 ydm()返回参数 y,m,d def ydm(y, m, d): sum = 0 if y % 400 == 0 or y % 100 != 0 and y % 4 == 0: #闰年 a = [31, 29, 31, 30, 31, 30, 31, 31, 30, 30, 30, 31] #是闰年使用这个列表 else: a = [31, 28, 31, 30, 31, 30, 31, 31, 30, 30, 30, 31]#不是闰年使用这个列表 for i in range(1, 13):原创 2020-09-14 11:01:47 · 2140 阅读 · 1 评论 -
Python基础入门
1.Python安装 要检查是否已在 Windows PC (个人电脑)上安装了 python,请在开始栏中寻找 Python 或在命令行(cmd.exe)上运行以下命令: python --version 没有安装则官网下载 https://www.python.org/ 编辑Python工具vscode https://code.visualstudio.com/ vscode安装插件: 1,Python 2.Tabnine(代码提示功能) 3.chinese(中文) 4.BracketPaair原创 2020-09-13 20:11:33 · 475 阅读 · 0 评论 -
python_画图源码
import turtle t = turtle.Pen() t.speed(1) t.pensize(1) t.penup() t.goto(10, 0) t.pendown() t.color("red") t.begin_fill() t.fillcolor("red") t.circle(50) t.end_fill() t.penup() t.goto(60, 50) t.pendown() t.color("blue") t.begin_fill原创 2020-09-07 19:43:56 · 880 阅读 · 0 评论