Python
Webben
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Python抓取某平台代码
#!/usr/bin/python# -*- coding: GBK -*-import os, sys, timeimport requestsimport arrowimport hashlibfrom unipath import Pathdef file_get_contents( url): s = requests.Session() headers={ "Accept":"text/html,application/xhtml+xml,applic原创 2020-11-04 18:33:21 · 292 阅读 · 1 评论 -
Python Selenium库的使用
知识产权保护,超级传送门:Python Selenium库的使用http://www.testclass.net/selenium_python/原创 2020-10-13 15:04:44 · 258 阅读 · 0 评论 -
Python打开不同编码文件
import sys, os, chardetfiles = [ 'utf8.txt', 'gb2312.txt',]for filename in files: # 采样长度,最长采样长度为100,可调节 sample_len = min( 100, os.path.getsize( filename)) #读取片段bytes raw = open( filename, '...原创 2019-12-04 17:11:29 · 1184 阅读 · 0 评论 -
Python3.7 Linux docx和doc文档转码文本
Python3.7 转码文本Docx 转文本安装pip3 install python-docx#!/usr/bin/python3.7def doc2text(): doc = Document( filename) for para in doc.paragraphs: rows.append( para.text) return "\n".join( rows)a...原创 2019-12-02 10:08:15 · 1609 阅读 · 0 评论 -
Python 列表切割(用于多进程)
话不多,上代码。def get_chunks(iterable, chunks=1): # This is from http://stackoverflow.com/a/2136090/2073595 lst = list(iterable) return [lst[i::chunks] for i in range(chunks)]...转载 2019-10-28 18:08:00 · 531 阅读 · 0 评论 -
Python 包的编写与使用
一、模块(Module)创建一个 文件夹 或者 文件。├── run.py├── calculate│ ├── add.py│ ├── divde.py│ ├── multi.py│ └── sub.py调用模块。# Filename:add.pydef add( a, b): return a+ b# Filename:run.pyfrom ca...原创 2019-10-25 11:15:16 · 501 阅读 · 0 评论 -
Python网络编程之线程队列(queue)
A机器负责发送任务和接受结果:#task_master.pyimport random,time,queuefrom multiprocessing.managers import BaseManager task_queue = queue.Queue()result_queue = queue.Queue() class QueueManager(BaseManager): ...原创 2019-10-15 17:53:27 · 645 阅读 · 0 评论 -
Python subprocess模块功能与常见用法实例详解
本文实例讲述了Python subprocess模块功能与常见用法。分享给大家供大家参考,具体如下:一、简介subprocess最早在2.4版本引入。用来生成子进程,并可以通过管道连接他们的输入/输出/错误,以及获得他们的返回值。subprocess用来替换多个旧模块和函数:os.systemos.spawn*os.popen*popen2.*commands.*运行py...原创 2019-10-15 16:24:47 · 1441 阅读 · 0 评论 -
Python 日期时间模块 Arrow库
我个人在 Python 中经常使用 arrow 模块替代datetime模块,个人认为非常好用,安装pip install arrow使用例子日常使用# 获取当前时区当前时间,返回 arrow 对象# <Arrow [2019-10-15T15:00:59.995577+08:00]>t = arrow.now()# 获取格林尼治时间,返回 arrow 对象 # &...原创 2019-10-15 15:36:19 · 921 阅读 · 0 评论 -
Python 路径操作工具 pathlib
在 python 当中,如果你想控制路径,基本上绕不开 os.path。我希望看完这篇文章以后,熟练使用 python 的你能立刻开始使用 pathlib 模块,一刻也不要耽误。pathlib 相对于 os.path 有以下优势:pathlib 导入更加清晰;采用面向对象编程,能同时存储更多状态,os.path 返回的通常只有一个字符串;pathlib 使用更简单。获取路径相关信息...转载 2019-10-15 11:53:26 · 500 阅读 · 0 评论 -
Python 操作数据库之 records
今天要介绍的这个python第三方库非常厉害,完美操作各种数据库。名字叫 records, 在网上很少有这个库的相关资料,但是在开源社区可是很火热的哦。如果这还不能打消你的顾虑,再告诉你一件事:如果你用 python 编程,你一定听过 requests, 这两个库是同一个作者写的。.records 包地址:https://pypi.python.org/pipy/records/一、快速使...原创 2019-10-15 11:29:07 · 1812 阅读 · 0 评论 -
pandas.Series 详解
pandas.Series 详解原创 2019-07-11 11:18:06 · 389 阅读 · 0 评论 -
Linux下编译安装 Python 3.8
1、介绍Linux下默认系统自带python2.6的版本,这个版本被系统很多程序所依赖,所以不建议删除,如果使用最新的Python3那么我们知道编译安装源码包和系统默认包之间是没有任何影响的,所以可以安装python3和python2共存。Python优点: 1.易于学习:Python有相对较少的关键字,结构简单,和一个明确定义的语法,学习起来更加简单。 2.易于阅读:Python代码定义原创 2017-07-07 16:26:47 · 2491 阅读 · 0 评论 -
Python 3.* 安装 web.py
Python 3.* 安装 web.py准备官方文档:http://webpy.org/ Python 3 和 pip3python -V #Python 3.5.6pip -V #pip 18.0 from /usr/local/python/lib/python3.5/site-packages/pip (python 3.5)...原创 2018-09-07 13:34:57 · 1990 阅读 · 0 评论 -
Python 3 和 Django 常用安装包
包名包命令包地址文档时间(arrow)pip install arrowhttps://pypi.org/project/arrow/数据库(mysql-connector)pip install mysql-connectorhttps://pypi.org/project/mysql-connector/日志(logging)pip insta...原创 2018-10-22 11:02:25 · 1122 阅读 · 0 评论 -
Python3 日志输出及配置
Python3 日志输出及配置目录结构如下:.├── conf│ ├── development.conf│ ├── logging.conf│ ├── production.conf│ └── testing.conf├── data├── logs│ ├── root.log│ └── webben.log└── src ├── cl...原创 2018-11-08 11:51:39 · 3203 阅读 · 0 评论 -
Python3 Xml 转为Dict(字典)
import xmltodictimport jsondef xml2dict(): file_object = open('1111111018378_20181203214626.xml',encoding = 'utf-8') ...原创 2018-12-04 14:21:38 · 9134 阅读 · 1 评论 -
Python How to fix error: django.db.utils.NotSupportedError: URIs not supported (转)
原文:https://blog.youkuaiyun.com/zhuangmezhuang/article/details/82776272一、问题The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/tech/poc/env/...转载 2019-03-20 15:38:29 · 612 阅读 · 0 评论 -
Python 安装 mysqlclient mysql_config not found 错误
错误信息:# 重点mysqlclient mysql_config not foundxxxxxxxxxxCommand "python setup.py egg_info" failed with error code 1 in原因是因为 mysql_config 没找到,需要安装mysql 和 mysql-clientCentos 解决办法yum install mysql-d...原创 2019-03-22 17:41:04 · 782 阅读 · 0 评论 -
pandas.read_csv 参数详解
pandas.read_csv 参数详解def parser_f(filepath_or_buffer, sep=sep, delimiter=None, # Column and Index Locations and Names header='infer...原创 2019-07-09 16:07:16 · 1125 阅读 · 0 评论 -
pandas.DataFrame 详解
pandas.DataFrame原创 2019-07-11 11:16:35 · 766 阅读 · 0 评论 -
Python 安装 SQLAlchemy(未完成)
安装Python-pipyum -y install epel-releaseyum -y install python-pip安装SQLAlchemypip install sqlalchemy或者# 下载sqlalchemygit clone https://github.com/zzzeek/sqlalchemy.gitcd sqlalchemy/# 安装python3 setup.原创 2017-07-12 11:56:19 · 1017 阅读 · 0 评论
分享