Python 常用库速查手册

Python常用库速查手册:99天掌握核心工具 Python作为主流编程语言,其强大的生态系统离不开各种功能库的支持。理解常用库的工作原理和高效使用方法,是提升开发效率的关键。通过向量化计算、异步IO等技术原理,pandas、requests等库大幅提升了数据处理和网络通信性能。在实际工程中,合理应用这些库可以解决数据清洗、API调用、并发处理等常见场景需求。本速查手册精选PyPI高下载量库,提供pandas高效操作模板和requests高级用法等实战内容,帮助开发者快速解决threading多线程和datetime时区处理等典型问题。 阅读详情

一句话宗旨:Python 之所以被称为“胶水语言”,就是因为它能把各领域的库粘在一起干活。本手册分类介绍常用库、功能简述、核心 API 以及最小可用代码,让你在写代码时一查就能用。
适用人群:爬虫工程师、数据分析师、AI 工程师、自动化运维、科研人员、Python 开发者。

1. 网络请求与爬虫类

1.1 requests — 人类友好的 HTTP 客户端

import requests

# GET 请求
r = requests.get("https://httpbin.org/get", params={"q": "python"})
print(r.status_code, r.json())

# POST 请求
r = requests.post("https://httpbin.org/post", data={"name": "Tom"})
print(r.text)

# 带会话(保持 Cookie)
s = requests.Session()
s.get("https://example.com/login")

简单直观、支持 SSL、代理、Cookie、文件上传、会话保持。

1.2 aiohttp — 异步 HTTP 请求

import aiohttp, asyncio

async def fetch(url):
    async with aiohttp.ClientSession() as s:
        async with s.get(url) as resp:
            return await resp.text()

asyncio.run(fetch("https://httpbin.org/get"))

高并发请求,爬虫性能提升 10 倍。

1.3 httpx — 现代化异步 HTTP 客户端

import httpx
with httpx.Client() as client:
    r = client.get("https://httpbin.org/get")
    print(r.json())

支持 HTTP/1.1、HTTP/2,兼容同步 + 异步,requests 升级替代品。

1.4 beautifulsoup4 — HTML 解析神器

from bs4 import BeautifulSoup
html = "<div><p>Hello <b>Python</b></p></div>"
soup = BeautifulSoup(html, "html.parser")
print(soup.find("b").text)

API 直观,支持 HTML、XML,多解析器。

1.5 lxml — XPath 提取

from lxml import etree
html = "<div><p>Hello <b>Python</b></p></div>"
tree = etree.HTML(html)
print(tree.xpath("//b/text()"))

解析速度快,XPath 灵活,适合复杂页面。

1.6 selenium — 浏览器自动化

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://www.python.org")
print(driver.title)
driver.quit()

支持 Chrome/Firefox 等真实浏览器,处理 JS 渲染页面。

1.7 playwright — 新一代浏览器自动化

from playwright.sync
Python常用库速查手册:NumPy、Pandas、Matplotlib实战代码集 在Python数据科学领域,NumPy、Pandas和Matplotlib构成了基础工具链的核心三件套。NumPy提供高效的多维数组运算能力,其ndarray数据结构是科学计算的基石;Pandas的DataFrame则为结构化数据处理提供了SQL般的操作体验;Matplotlib则实现了从基础图表到复杂可视化的完整解决方案。这些库通过向量化运算和内存优化技术,显著提升了数据处理效率,被广泛应用于金融分析、机器学习、科研计算等领域。本文整理的高频使用代码片段覆盖了数组操作、数据清洗、统计分析等典型场景,特别针 阅读详情

相关推荐

Python语法速查手册

Python是一种高级编程语言,它的强大功能也使它成为数据科学、Web开发、游戏编程等领域的一流工具。但由于其高门槛,并非所有人都可以快速上手,因此,我整理了一些基础知识和Python语法,帮助大家快速熟悉Python编程。本文适合刚入门的初学者学习,希望通过阅读本文,能够掌握Python语法和相关用法,提升编程能力,加快自己的职业生涯。Python是一种解释型、面向对象、动态数据类型的高级编程语言。它具有简洁、易读、明确的代码风格,在代码量不大的情况下,Python通常被认为比其他语言更容易学习。

AI天才研究院 2428

python速查表和全套手册.rar

python速查表和全套手册,速查表比较有用,手册是挺旧了的。资源还是挺不错的啦,新手建议收藏,大佬请多指导

Python速查手册彩版.pdf

Python速查手册彩版.pdf

Python速查手册.rar

Python速查手册

Python3速查表手册全套完整中文PDF版最新版本

以下是对您提供的段落进行重新组织后的版本: --- **Python学习资源合集概览** 本套资源包含Python速查表和全套手册,旨在为初学者提供中英文PDF格式的基础知识梳理,以打下坚实的进阶学习基础。该资源简明扼要,方便随时查阅,是您手边必备的实用工具书。 **资源内容概览:** - **Numpy 速查表** - **Python3语法速查本** - **Python速查手册彩版** - **Bokeh** - **Keras** - **Scikit-Learn** - **Numpy 基础** - **Pandas 基础** - **Pandas 进阶** - **Matplotlib** - **Jupyter Notebook** **各部分详细介绍:** 1. **Bokeh**:Python的交互式可视化库,专门用于生成在浏览器中显示的大规模数据集的高性能可视化图表。 2. **Jupyter Notebook**:将代码与文本封装为三种类型的单元格——Markdown、代码与NBConvert,便于文档化和分享。 3. **Keras**:基于T

1.2 固态变压器:传统工频变压器的局限与SST的技术起源

本小节明确传统工频变压器在电力系统中的基础定位与核心工作特性,系统分析其在新型电力系统场景下的固有技术瓶颈,梳理固态变压器(Solid State Transformer, SST,又称电力电子变压器Power Electronic Transformer, PET)从概念提出到工程化成熟的完整演进路径,为后续SST技术优势、设计需求与规范符合性要求的讲解建立底层逻辑,同时对应GB/T 40429-2021《电力电子变压器通用技术要求》的需求制定背景。

技术工作者 660

FPGA音频处理入门:手把手教你用Verilog实现I2S接收模块(附完整代码)

本文详细介绍了如何使用Verilog在FPGA上实现I2S接收模块,涵盖I2S协议原理、Verilog架构设计、完整代码实现及优化技巧。通过实战案例,帮助开发者快速掌握数字音频处理技术,适用于嵌入式音频系统开发。

weixin_30335575的博客 418

FreeSWITCH实战:5分钟搞定阿里云SDM(MRCP-SERVER)语音机器人搭建(含Docker部署技巧)

本文详细介绍了如何利用FreeSWITCH与阿里云SDM(MRCP-SERVER)快速搭建高可用语音机器人,包括Docker部署技巧、系统调优及高可用架构设计。通过实战案例和优化建议,帮助开发者5分钟内完成部署,提升语音交互系统的性能和稳定性。

stone的博客 505

CAD制图

CAD制图可以提高设计效率和准确性,并方便文档的存档和交流,是现代工程设计中不可或缺的一部分。·CAD三维开发是指使用计算机程序和工具来创建、编辑和操作三维模型、图形和设计的过程。它在工程、建筑、制造和游戏等领域广泛应用。CAD三维开发可能涉及到复杂的图形算法、性能优化、并行计算等方面的内容,因此需要深入学习和实践,以提高开发的效率和质量。

RZer的博客 1654

C++和OpenGL实现3D游戏编程【连载7】——文字和汉字的显示(附源码)

上一节我们讨论了纹理在二维平面内不规则图形贴图的相关基础操作,本节我们开始了解游戏里文字以及汉字的显示方法。本节课我们将从基本的ASCII字符显示,拓展到中文字符的显示,最后再讲到纹理字符的显示,并对各种文字显示方法的优缺点和使用场景进行分析,这节课将使用到显示列表、兼容视图、屏幕图形转纹理等操作。

zhooyu的博客 1500

uniapp - 实现苹果App打包上架App Store应用商店详细教程,详解Hbuilder打包编译ipa发布上传到苹果ios软件商店全流程,提供云打包/离线本地打包ios、申请IOS苹果证书方法

uni-app,苹果ios,苹果app,打包编译,appstore应用商店,ipa发布到软件商店,uniapp的app苹果应用商店上架,上架苹果APPStore,uniApp打包的ipa文件上传到商店,上架苹果商城,审核失败,被拒绝,UniApp打包ipa文件,上架iOSAppStore流程指南,最新详细教程最全,Hbuilder打包发布iosapp,苹果云打包上线全过程,云打包IPA并上传到商店,打包iOSipa文件后怎么发布到应用商店,苹果证书申请教程,ios证书申请,mac电脑,审核很久

🏆 前端领域优质创作者 1万+

初学者入门YOLO目标检测:从懵圈到上手,这篇文章讲透所有核心(附学习路径+避坑指南)

目标:比如训练一个“检测苹果和橘子”的模型,或者“检测人脸”的模型;任务:学会用LabelImg标注数据,制作YOLO格式的数据集,用命令行训练模型;关键:不用追求高精度,能训练出一个能检测出目标的模型就行。很多初学者卡在入门阶段,不是因为智商不够,而是因为“想太多,做太少”——总觉得要把所有原理搞懂才能动手,结果越想越怕,最后放弃。先动手,再动脑。先跑通一个案例,获得成就感;再制作自定义数据集,训练简单模型;最后再回头去理解原理,优化模型。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 691

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: js加密逆向
下一篇: Pandas 2.0 + Arrow 加速、Dask vs Ray、Plotly 可视化:数据分析的未来
Ghostycode
博客等级 码龄5年 132粉丝 19原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值