python编程
bailixuance
拒绝拖延,做一个执行力强的人。
做好精力分配。
展开
-
Anconda 管理多个python版本
1、conda --version查看conda的版本可知conda版本是4.4.10 2、conda info --envs查看已有的python版本信息目前只有一个python环境 3、conda create --name python35 python=3.5创建一个环境名字叫python35的python3.5环境即:这个环境是...原创 2018-11-24 11:58:04 · 1823 阅读 · 0 评论 -
Python项目自动生成requirements.txt
在复现别人的项目时,别人的项目可能会需要很多依赖,一个一个安装有点麻烦,这里可以使用python库来自动安装依赖1、安装pipreqspip install pipreqs2、cd到项目所在路径3、执行命令pipreqs ./此时可见生成了requirements.txt文件,打开该文件可见所需要安装的依赖4、执行pip install -...原创 2018-11-24 13:19:13 · 1207 阅读 · 1 评论 -
python包安装pip使用国内镜像地址
清华:https://pypi.tuna.tsinghua.edu.cn/simple阿里云:http://mirrors.aliyun.com/pypi/simple/中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/华中理工大学:http://pypi.hustunique.com/山东理工大学:http://pypi.sdutlin...原创 2018-11-24 13:27:01 · 3614 阅读 · 0 评论 -
python 安装cv2
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python原创 2018-11-24 13:47:51 · 4433 阅读 · 1 评论 -
python字符串前面加u,r,b的含义
u/U:表示unicode字符串 不是仅仅是针对中文, 可以针对任何的字符串,代表是对字符串进行unicode编码。 一般英文字符在使用各种编码下, 基本都可以正常解析, 所以一般不带u;但是中文, 必须表明所需编码, 否则一旦编码转换就会出现乱码。 建议所有编码方式采用utf8r/R:非转义的原始字符串 与普通字符相比,其他相对特殊的字符,其中可能包含转义字符,即那些,反斜杠加上对应...转载 2018-11-30 18:39:44 · 190 阅读 · 0 评论 -
python爬虫实战:猫眼电影我不是药神评论
一、简介有了上次爬取豆瓣短评的实战,我们爬取猫眼就有经验了,环境:win10,notebook,python3.6,整体步骤也是分析网页,爬取策略,代码编写,本地保存 二、网页分析我不是药神猫眼主页:http://maoyan.com/films/1200486网页模式只能看数条评论,我们使用手机模式刷新网页,往下拉就是评论4就是我们要找的url,但...原创 2018-12-04 08:57:24 · 3501 阅读 · 1 评论 -
python中reduce函数详解
1、python2 中,reduce函数是内置函数2、python3 中,函数被移到了functools模块中3、官方文档:reduce(...)reduce(function, sequence[, initial]) -> valueApply a function of two arguments cumulatively to the items of a sequ...原创 2018-12-19 15:47:46 · 13964 阅读 · 1 评论 -
python 3.6安装cPickle
1、在python2.X中,需要安装cPickle,2、在python3.X中,这个包已被别的包替换,使用以下语句即可:import _pickle as cPickle原创 2018-12-17 19:16:42 · 29987 阅读 · 2 评论 -
python 去除非中文字符
直接上代码:import redef find_chinese(file): pattern = re.compile(r'[^\u4e00-\u9fa5]') chinese = re.sub(pattern, '', file) print(chinese)def find_unchinese(file): pattern = re.compil...原创 2019-04-26 16:13:32 · 21074 阅读 · 8 评论