![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
ajaxPost293614
你就是你最大的资本。
展开
-
scrapy 的入门使用超级详细
记录一下scrapy的安装和实践操作的流程1.安装pip install Scrapy2.创建scrapy项目project是蜘蛛名字scrapy startproject project3.创建scrapy res.py蜘蛛文件保存在spiders目录下4.查看是否可正常访问网站scrapy shell http://lab.scrapyd.cn看到response 返回200 说明此网站支持爬虫5.命令行测试 dom 元...原创 2021-10-27 11:58:51 · 1251 阅读 · 0 评论 -
matplotlib基础(6)之箱线图 boxplot
from matplotlib import colorsimport matplotlib.pyplot as pltimport numpy as npfrom numpy.core.fromnumeric import sizefrom numpy.core.shape_base import stackimport pandas as pd# 箱线图 boxplot(data) data:float or array-like 数据处理查询异常值 """在上面 异常值.原创 2021-08-14 16:53:53 · 525 阅读 · 0 评论 -
matplotlib基础(5)之直方图 hist
from matplotlib import colorsimport matplotlib.pyplot as pltimport numpy as npfrom numpy.core.fromnumeric import size# 直方图 hist(data) data:float or array-likenp.random.seed(2) # 保持下面的数据多次生成一样# normal:正态分布 平均值9000 标准差3000data = np.random.normal(.原创 2021-08-14 16:51:17 · 171 阅读 · 0 评论 -
matplotlib基础(4)之饼图 pie
from matplotlib import colorsimport matplotlib.pyplot as pltimport numpy as npfrom numpy.core.fromnumeric import size# 饼图 x = ['Q1', 'Q2', 'Q3', 'Q4', ]y = [10, 30, 20, 48]plt.axes(aspect=1) # pie本身是椭圆, aspect=1使其为圆形"""autopct:展示数值占比 %2.f保留两.原创 2021-08-14 16:48:26 · 555 阅读 · 0 评论 -
np.random.normal()正态分布函数 默认值
默认:numpy.random.normal(loc=0.0,scale=1.0,size=None)"""平均值0,标准差1 100个值"""data = np.random.normal(size=100)print(data)打印:直方图:plt.hist(data)例:"""normal:正态分布平均值9000标准差3000 300个数值"""data=np.random.normal(9000,3000,si...原创 2021-08-13 14:12:52 · 1139 阅读 · 0 评论 -
matplotlib基础(3)之柱状图bar
from matplotlib import colorsimport matplotlib.pyplot as pltimport numpy as npfrom numpy.core.fromnumeric import size# 柱状图 barx = ['Q1', 'Q2', 'Q3', 'Q4', ]y = [10, 32, 21, 18]rect = plt.bar(x, y, width=0.3)plt.grid(True) # 网格# 绘制标度值 enume.原创 2021-08-13 10:41:12 · 394 阅读 · 0 评论 -
matplotlib基础(2)之折线图plot
from matplotlib import colorsimport matplotlib.pyplot as pltimport numpy as npfrom numpy.core.fromnumeric import size# 折现图 plot# np.random.random((3, 4)) 生成3行4列的浮点数,浮点数都是从0-1中随机,维度:2x = np.arange(10)np.random.seed(3) # 设置随机数种子, 每次都相同y = np.r.原创 2021-08-13 10:29:11 · 166 阅读 · 0 评论 -
matplotlib基础(1)之散点图scatter
1.首先安装matplotlibpip install matplotlib2.引入matplotlibimport matplotlib.pyplot as pltimport numpy as np3.matplotlib散点图# 散点图 scatter# uniform 均匀分布随机采样arr1 = np.random.uniform(0.0, 5.0, size=(100, 2)) # 100行 2列的元组print(arr1)arr2 = np.ra原创 2021-08-13 10:21:20 · 324 阅读 · 0 评论 -
pandas之数据分组和时间序列
groupby,unique,date_range,to_datetime,resample# hello pandas""" Series : 列 DataFrame : 表"""import numpy as npimport pandas as pd#df_excel = pd.read_excel('./pandasFile/data.xlsx')print('\n12:')print(df_excel)""" 日期 名称...原创 2021-01-26 18:32:18 · 427 阅读 · 0 评论 -
FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be depreca
FutureWarning: Indexing with multiple keys (implicitly converted to a tuple of keys) will be deprecated, use a list instead.FutureWarning:将不推荐使用多个键(隐式转换为键的元组)进行索引,请改用列表。解决: [[ ** ]]grouped_sum = grouped[['金额','数量']].sum()此警告在pandas 1.0.0中引入。gro...原创 2021-01-26 10:52:50 · 4019 阅读 · 0 评论 -
pandas之数据排序和合并
rank,sort_index,merge,concat,info,describe# hello pandas""" Series : 列 DataFrame : 表"""import numpy as npimport pandas as pd# 对数据排序# 对列排序 seriesst = pd.Series(list('ACB'), index=[3, 1, 2])print('\n14:')print(st)"""3 A1 C2原创 2021-01-25 17:37:39 · 654 阅读 · 0 评论 -
pandas之数据选取(2)
query:查询isin:是否符合T:对调导入数据:read_table,read_csv,read_excel,read_html# hello pandas""" Series : 列 DataFrame : 表"""import numpy as npimport pandas as pd# padas 使用比较运算筛选数据data = { 'name': ['jack', 'mary', 'lily', 'bobo'], 'age':原创 2021-01-21 15:50:24 · 109 阅读 · 0 评论 -
pandas之数据选取(1)
# hello pandas""" Series : 列 DataFrame : 表"""import numpy as npimport pandas as pd# padas中数据选取操作data = { 'name': ['jack', 'mary', 'lily', 'bobo'], 'age': [19, 32, 22, 12], 'height': [165, 178, 182, 172]}df = pd.DataFrame(data,.原创 2021-01-20 18:02:26 · 171 阅读 · 0 评论 -
pandas之Series,DataFrame的简单操作
# hello pandas""" Series : 列 DataFrame : 表"""import pandas as pdprint(pd.__version__)# 定义列:ser = pd.Series(['张三', '李四', '王五'])print(ser)"""0 张三1 李四2 王五"""# 自定义列的索引:ser1 = pd.Series(['张三', '李四', '王五'], index=list(range(1, .原创 2021-01-18 15:53:49 · 122 阅读 · 0 评论 -
numpy简单操作
# Numpy 本质就是ndarray 多维数组(多位矩阵)Numpy重点:1.数组维度 shape,reshape 获得维度大小:A.shape => (3,5)2.数组切片 x = np.arange(15).reshape(3,5) x[0:2, 0:3] ***取前2行 前3列 3.数组合并 x = np.concatenate([x1,x2], axis = 1) // axis默认是0 代表行合并""" 安装 pip install...原创 2021-01-14 14:49:12 · 111 阅读 · 0 评论 -
python练习(3)
python练习(2)https://blog.csdn.net/caoyan0829/article/details/111572816"""11.学员信息管理系统 1.学员信息数据源 2.查看学员信息 3.添加学员信息 4.删除学员信息 5.退出系统 6.界面和交互"""# 1.学员信息数据源stu_list = [ { 'name': 'xiaohong', 'age': 18, 'c原创 2020-12-23 10:00:37 · 146 阅读 · 0 评论 -
python练习(2)
"""6.列表去重"""l6 = [1, 1, 2, 3, 54, 3, 2, 1]print(list(set(l6))) # 先转集合再转回列表"""7.自定义 abs"""def my_abs(x): if not isinstance(x, (int, float)): raise TypeError('只支持整数和浮点数') if x >= 0: return x else: return -.原创 2020-12-23 09:52:58 · 276 阅读 · 0 评论 -
python练习(1)
"""1.杨辉三角 [1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1.原创 2020-12-23 09:25:38 · 180 阅读 · 0 评论 -
python学习(16)- 装饰器
python学习(15)https://blog.csdn.net/caoyan0829/article/details/111296781装饰器:print('')"""开放:对外扩展是开放封闭:对内修改是封闭扩展使用 装饰器"""# 函数参数def check_login(fun): def check(*args, **kwargs): print('验证登录') return fun(*args, **kwargs) # 相当原创 2020-12-18 10:19:07 · 94 阅读 · 0 评论 -
python学习(15)- 迭代器
python学习(14)https://blog.csdn.net/caoyan0829/article/details/111292662迭代器:print('')"""迭代器 优点:惰性计算(节省内存) 不依赖索引,可以遍历没有索引的对象 如字典,集合 缺点:无法获取迭代器长度 只能往后取值,不能倒序取值 1.可迭代器对象 Iterable 能用for循环遍历的数据 列表list,字典dict,元组tu原创 2020-12-16 17:35:43 · 136 阅读 · 0 评论 -
python学习(14)- 生成器
Python学习(13)https://blog.csdn.net/caoyan0829/article/details/111252490生成器:"""GeneratorExitgenerator生成器:一边循环一边计算来生成想要的数字"""l = [i for i in range(20) if i % 2 == 0]print(l) # [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]g = (i for i in range(20) if i % 2原创 2020-12-16 17:04:33 · 127 阅读 · 0 评论 -
python学习(13)- 三大式
Python学习(12)https://blog.csdn.net/caoyan0829/article/details/111209604三大式:1.列表推导式#简化代码,但是阅读性更复杂,不宜维护"""1"""l = []for i in range(10): l.append(i)print(l) # [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]# 列表推导式l1 = [i for i in range(10)]print(l1) # [原创 2020-12-16 11:38:41 · 268 阅读 · 2 评论 -
python学习(12)- 模块与包
模块与包:#1. 调用tools文件中的 add,jian 函数from tools import add# def add(x, y):# result = x + y# return resultresult = add(1,2)print(result)#2. 引入文件中所有函数 不推荐#重复函数名称的 后面会覆盖前面的from tools import *result2 = jian(3,1)print(result2)print('end').原创 2020-12-15 14:13:39 · 428 阅读 · 3 评论 -
python学习(11)- 捕获异常
异常处理# 捕获具体异常 一个try: open('10.txt', 'r') # 没有10.txt文件,报错FileNotFoundErrorexcept FileNotFoundError: print('没有该文件')# 捕获具体异常 多个try: print(1 / 0) # 报错 ZeroDivisionError: division by zero open('10.txt', 'r') # 没有10.txt文件,报错FileNotFoun原创 2020-12-12 11:38:51 · 138 阅读 · 0 评论 -
python学习(10)- 文件操作
文件的操作"""r 只读 运行时 文件不存在报错w 写文件,不存在则创建,如果已存在则覆盖a 追加(和w差不多,但是不会覆盖)rb 二进制读 音乐,图片,视频wb 二进制写ab二进制追加r+ 读写 运行时 文件不存在报错w+ 读写a+ 追加读写rb+ 二进制读写wb+ 二进制读写ab+ 二进制追加"""# f = open('路径',"模式")f = open('1.txt',"a")# #手动关闭f.close()b = open('2.txt','a+.原创 2020-12-03 14:27:51 · 201 阅读 · 0 评论 -
python学习(9)- 面向对象3
面向对象的三大特性:、"""封装1.把属性封装到对象当中,方便调用2.把相同的功能封装同一方法中,方便调用""""""继承1.顶级父类是Object2.如果不同类中有相同的行为或属性 可以用继承""""""多态1.同一种事务,具有多种形态2.前提要有继承关系"""class Animal(object): # 父类 基类 def __init__(self): self.name = "小黑" # 私有属性和行为.原创 2020-11-26 15:57:32 · 124 阅读 · 0 评论 -
python学习(8)- 面向对象2
面向对象:# 练习class Home(): def __init__(self,colour,floor): self.colour = colour self.floor = floor def __str__(self): return '将内存地址变成这个' def sleep(self): print('进屋睡觉') def cook(self,type): print('原创 2020-11-19 15:09:19 · 124 阅读 · 0 评论 -
python学习(7)- 面向对象1
面向对象:# 类 class 相同属性 相同行为# 对象 对象是类的 实例# 车类class MyCar(): colour = '红色' # 类 里面的函数要加self def run(self): print('跑') def music(self): print('听音乐')mbc = MyCar() # 创建了一个面包车对象mbc.run() # 调用对象 跑的方法mbc.music() # 调用对象原创 2020-11-18 17:40:35 · 117 阅读 · 0 评论 -
python学习(6)- 函数
函数:# 函数 def 实现代码复用# 声明函数def print_name(): print('我叫老李')# 调用函数print_name()def add(x, y, z=4): # x,y形参 z 默认参数 print(x, y, z)# 可变参数 *args,**kwargsdef demo(x, y, z=2, *args, **kwargs): isum = 0 isum = x + y + z for i in原创 2020-11-18 11:04:32 · 182 阅读 · 0 评论 -
python学习(5)- 集合和字符串
集合:#集合 set 一个没有重复元素的数据结构 没有顺序## 集合 可变 无序# 字典 可变 无序# 列表 可变 有顺序# 元组 不可变 有顺序s = set({}) # s = {}是字典类型 空集合print(type(s))#增加s.add(1)s.add(1)s.add(2)#合并s.update([6,7]) #{1, 2, 6, 7} update 仅支持添加 list、元组,集合,字典print(s) #{1}原创 2020-11-17 09:59:54 · 125 阅读 · 0 评论 -
python学习大纲
需要的私我 发你xmind原创 2020-11-16 16:37:40 · 95 阅读 · 0 评论 -
python学习(4)- 字典和元组
字典:# 就是键值对 key:value 字典是没有序的obj = {'age':12}#曾obj['name'] = '老王'print(obj)#查 get()查找不会报错 []查存在的a = obj['age']# c = obj['age1']e = obj.get('age1')print(a)# print(c)print(e)#修改obj['name'] = '张三'print(obj)#练习# b = {}# b['name'] =原创 2020-11-16 15:22:01 · 119 阅读 · 0 评论 -
python学习(3)- 循环语句和列表
循环语句"""while 条件: 代码块"""# while 1>0:# print("对")# \n 换行 ctrl + 左键点击print 查看原生apiprint("老王", end="") #取消print默认的换行print("老张")import randomnum = random.randint(1,100)# while True:# inum = int(input("输入数字"))# if inum原创 2020-11-13 10:31:02 · 169 阅读 · 0 评论 -
python学习(2)- 分支语句
1.%的展示num = input('输入数字')print('%s%%'%num) #10%print("{}%".format(num)) #10%2.分支语句 if elif elsenum = int(input("数字"))if (num > 10): print("数字大于10")elif (num > 5): print("数字大于5,小于等于10")else: print("数字小于等于5")#逻辑运算符 and并且(.原创 2020-11-12 11:35:41 · 170 阅读 · 2 评论 -
python学习(1)- 变量
1.打印print('hello python') # hello python2.运算print(8 // 2) # 4 取商数print(6 % 2) # 0 取余数print(2 ** 3) # 8 幂 2的三次方3.注释# 单行注释""" 多行注释 三个双引号 ctrl+alt+l 文件格式化 Code => reformat code"""4.变量name = "老王" #把老赵赋值给name .原创 2020-11-11 11:00:02 · 208 阅读 · 2 评论 -
pycharm代码格式化
1. 在Code =》 reformat Code2.快捷键 ctrl + alt + l原创 2020-11-11 10:10:56 · 459 阅读 · 0 评论