自从收了这些Python库 头发都不脱了!
01
图片处理
1. pip install pillow
2. from PIL import Image
3. import numpy as np
4.
5. a = np.array(Image.open('test.jpg'))
6. b = [255,255,255] - a
7. im = Image.fromarray(b.astype('uint8'))
8. im.save('new.jpg')
02
youtube-dl下载国外视频
1. #https://github.com/rg3/youtube-dl/
2. pip install youtube-dl #直接安装youtube-dl
3. pip install -U youtube-dl #安装youtube-dl并更新
4. youtube-dl "http://www.youtube.com/watch?v=-wNyEUrxzFU"
03
查看对象的全部属性和方法
1. pip install pdir2
2. >>> import pdir,requests
3. >>> pdir(requests)
4. module attribute:
5. __cached__, __file__, __loader__, __name__, __package__, __path__, __spec__
6. other:
7. __author__, __build__, __builtins__, __copyright__, __license__, __title__,
8. __version__, _internal_utils, adapters, api, auth, certs, codes, compat, cookies
9. , exceptions, hooks, logging, models, packages, pyopenssl, sessions, status_code
10. s, structures, utils, warnings
11. special attribute:
12. __doc__
13. class:
14. NullHandler: This handler does nothing. It's intended to be used to avoid th
15. e
16. PreparedRequest: The fully mutable :class:`PreparedRequest <PreparedRequest>
17. ` object,
18. Request: A user-created :class:`Request <Request>` object.
19. Response: The :class:`Response <Response>` object, which contains a
20. Session: A Requests session.
21. exception:
22. ConnectTimeout: The request timed out while trying to connect to the remote
23. server.
24. ConnectionError: A Connection error occurred.
25. DependencyWarning: Warned when an attempt is made to import a module with mi
26. ssing optional
27. FileModeWarning: A file was opened in text mode, but Requests determined its
28. binary length.
29. HTTPError: An HTTP error occurred.
30. ReadTimeout: The server did not send any data in the allotted amount of time
31. .
32. RequestException: There was an ambiguous exception that occurred while handl
33. ing your
34. Timeout: The request timed out.
35. TooManyRedirects: Too many redirects.
36. URLRequired: A valid URL is required to make a request.
37. function:
38. delete: Sends a DELETE request.
39. get: Sends a GET request.
40. head: Sends a HEAD request.
41. options: Sends a OPTIONS request.
42. patch: Sends a PATCH request.
43. post: Sends a POST request.
44. put: Sends a PUT request.
45. request: Constructs and sends a :class:`Request <Request>`.
46. session: Returns a :class:`Session` for context-management.
04
Python 玩转网易云音乐
1. #https://github.com/xiyouMc/ncmbot
2. pip install ncmbot
3. import ncmbot
4. #登录
5. bot = ncmbot.login(phone='xxx', password='yyy')
6. bot.content # bot.json()
7. #获取用户歌单
8. ncmbot.user_play_list(uid='36554272')
05
下载视频字幕
1. #https://github.com/gyh1621/GetSubtitles
2. pip install getsub
06
Python 财经数据接口包
1. # https://github.com/waditu/tushare
2. pip install tushare
3. import tushare as ts
4. #一次性获取最近一个日交易日所有股票的交易数据
5. ts.get_today_all()
6.
7. 代码,名称,涨跌幅,现价,开盘价,最高价,最低价,最日收盘价,成交量,换手率
8. code name changepercent trade open high low settlement \
9. 0 002738 中矿资源 10.023 19.32 19.32 19.32 19.32 17.56
10. 1 300410 正业科技 10.022 25.03 25.03 25.03 25.03 22.75
11. 2 002736 国信证券 10.013 16.37 16.37 16.37 16.37 14.88
12. 3 300412 迦南科技 10.010 31.54 31.54 31.54 31.54 28.67
13. 4 300411 金盾股份 10.007 29.68 29.68 29.68 29.68 26.98
14. 5 603636 南威软件 10.006 38.15 38.15 38.15 38.15 34.68
15. 6 002664 信质电机 10.004 30.68 29.00 30.68 28.30 27.89
16. 7 300367 东方网力 10.004 86.76 78.00 86.76 77.87 78.87
17. 8 601299 中国北车 10.000 11.44 11.44 11.44 11.29 10.40
18. 9 601880 大连港 10.000 5.72 5.34 5.72 5.22 5.20
19. 10 000856 冀东装备 10.000 8.91 8.18 8.91 8.18 8.10
07
开源漏洞靶场
1. # https://github.com/phith0n/vulhub 安装pip
2. curl -s https://bootstrap.pypa.io/get-pip.py | python3
3.
4. # 安装docker
5. apt-get update && apt-get install docker.io
6.
7. # 启动docker服务
8. service docker start
9.
10. # 安装compose
11. pip install docker-compose
12. # 拉取项目
13. git clone git@github.com:phith0n/vulhub.git
14. cd vulhub
15.
16. # 进入某一个漏洞/环境的目录
17. cd nginx_php5_mysql
18.
19. # 自动化编译环境
20. docker-compose build
21.
22. # 启动整个环境
23. docker-compose up -d
24. #测试完成后,删除整个环境
25. docker-compose down
08
北京实时公交
1. #https://github.com/wong2/beijing_bus
2. pip install -r requirements.txt 安装依赖
3. python manage.py build_cache 获取离线数据,建立本地缓存
4. #项目自带了一个终端中的查询工具作为例子,运行: python manage.py cli
5. >>> from beijing_bus import BeijingBus
6. >>> lines = BeijingBus.get_all_lines()
7. >>> lines
8. [<Line: 运通122(农业展览馆-华纺易城公交场站)>, <Line: 运通101(广顺南大街北口-蓝龙家园)>, ...]
9. >>> lines = BeijingBus.search_lines('847')
10. >>> lines
11. [<Line: 847(马甸桥西-雷庄村)>, <Line: 847(雷庄村-马甸桥西)>]
12. >>> line = lines[0]
13. >>> print line.id, line.name
14. 541 847(马甸桥西-雷庄村)
15. >>> line.stations
16. [<Station 马甸桥西>, <Station 马甸桥东>, <Station 安华桥西>, ...]
17. >>> station = line.stations[0]
18. >>> print station.name, station.lat, station.lon
19. 马甸桥西 39.967721 116.372921
20. >>> line.get_realtime_data(1) # 参数为站点的序号,从1开始
21. [
22. {
23. 'id': 公交车id,
24. 'lat': 公交车的位置,
25. 'lon': 公交车位置,
26. 'next_station_name': 下一站的名字,
27. 'next_station_num': 下一站的序号,
28. 'next_station_distance': 离下一站的距离,
29. 'next_station_arriving_time': 预计到达下一站的时间,
30. 'station_distance': 离本站的距离,
31. 'station_arriving_time': 预计到达本站的时间,
32. },
33. ...
34. ]
09
文章提取器
1. #https://github.com/grangier/python-goose
2. git clone https://github.com/grangier/python-goose.git
3. cd python-goose
4. pip install -r requirements.txt
5. python setup.py install
6.
7. >>> from goose import Goose
8. >>> from goose.text import StopWordsChinese
9. >>> url = 'http://www.bbc.co.uk/zhongwen/simp/chinese_news/2012/12/121210_hongkong_politics.shtml'
10. >>> g = Goose({'stopwords_class': StopWordsChinese})
11. >>> article = g.extract(url=url)
12. >>> print article.cleaned_text[:150]
13. 香港行政长官梁振英在各方压力下就其大宅的违章建筑(僭建)问题到立法会接受质询,并向香港民众道歉。
14.
15. 梁振英在星期二(12月10日)的答问大会开始之际在其演说中道歉,但强调他在违章建筑问题上没有隐瞒的意图和动机。
16.
17. 一些亲北京阵营议员欢迎梁振英道歉,且认为应能获得香港民众接受,但这些议员也质问梁振英有
10
Python 艺术二维码生成器
1. #https://github.com/sylnsfar/qrcode
2. pip install MyQR
3. myqr https://github.com
4. myqr https://github.com -v 10 -l Q
11
伪装浏览器身份
1. #https://github.com/hellysmile/fake-useragent
2. pip install fake-useragent
3. from fake_useragent import UserAgent
4. ua = UserAgent()
5.
6. ua.ie
7. # Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US);
8. ua.msie
9. # Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)'
10. ua['Internet Explorer']
11. # Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB7.4; InfoPath.2; SV1; .NET CLR 3.3.69573; WOW64; en-US)
12. ua.opera
13. # Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11
14. ua.chrome
15. # Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2'
12
美化 curl
1. #https://github.com/reorx/httpstat
2. pip install httpstat
3. httpstat httpbin.org/get
13
python shell
1. #https://github.com/amoffat/sh
2. pip install sh
3. from sh import ifconfig
4. print ifconfig("eth0")
14
处理中文文本内容
1. #https://github.com/isnowfy/snownlp
2. pip install snownlp
3. from snownlp import SnowNLP
4.
5. s = SnowNLP(u'这个东西真心很赞')
6.
7. s.words # [u'这个', u'东西', u'真心',
8. # u'很', u'赞']
9.
10. s.tags # [(u'这个', u'r'), (u'东西', u'n'),
11. # (u'真心', u'd'), (u'很', u'd'),
12. # (u'赞', u'Vg')]
13.
14. s.sentiments # 0.9769663402895832 positive的概率
15.
16. s.pinyin # [u'zhe', u'ge', u'dong', u'xi',
17. # u'zhen', u'xin', u'hen', u'zan']
18.
19. s = SnowNLP(u'「繁體字」「繁體中文」的叫法在臺灣亦很常見。')
20.
21. s.han # u'「繁体字」「繁体中文」的叫法
22. # 在台湾亦很常见。'
15
抓取发放代理
1. #https://github.com/fate0/proxylist
2. pip install -U getproxy
3. ➜ ~ getproxy --help
4. Usage: getproxy [OPTIONS]
5.
6. Options:
7. --in-proxy TEXT Input proxy file
8. --out-proxy TEXT Output proxy file
9. --help Show this message and exit.
§ --in-proxy 可选参数,待验证的 proxies 列表文件
§ --out-proxy 可选参数,输出已验证的 proxies 列表文件,如果为空,则直接输出到终端
--in-proxy 文件格式和 --out-proxy 文件格式一致
16
zhihu api
1. pip install git+git://github.com/lzjun567/zhihu-api --upgrade
2. from zhihu import Zhihu
3. zhihu = Zhihu()
4. zhihu.user(user_slug="xiaoxiaodouzi")
5.
6. {'avatar_url_template': 'https://pic1.zhimg.com/v2-ca13758626bd7367febde704c66249ec_{size}.jpg',
7. 'badge': [],
8. 'name': '我是小号',
9. 'headline': '程序员',
10. 'gender': -1,
11. 'user_type': 'people',
12. 'is_advertiser': False,
13. 'avatar_url': 'https://pic1.zhimg.com/v2-ca13758626bd7367febde704c66249ec_is.jpg',
14. 'url': 'http://www.zhihu.com/api/v4/people/1da75b85900e00adb072e91c56fd9149', 'type': 'people',
15. 'url_token': 'xiaoxiaodouzi',
16. 'id': '1da75b85900e00adb072e91c56fd9149',
17. 'is_org': False}
17
Python 密码泄露查询模块
1. #https://github.com/lauixData/leakPasswd
2. pip install leakPasswd
3. import leakPasswd
4. leakPasswd.findBreach('taobao')
自从收了这些Python库 头发都不脱了!相关推荐
- python需要下载哪些软件-80%的人都不知道,全球Python库下载前10名
题图漫威宇宙英雄 Python的简洁性,不仅仅在于其语法简单,还有各种python库函数的支持,为大家节省了大量的时间和精力,所以网上有人戏称python的编程者为调包侠.但是你知道全球最受欢迎的py ...
- 送你38个常用的Python库,数值计算、可视化、机器学习等8大领域都有了
来源:大数据DT(ID:bigdatadt) 作者:李明江 张良均 周东平 张尚佳 内容摘编自<Python3智能数据分析快速入门> 本文约5200字,建议阅读10分钟. 本文为你总结了常 ...
- wxpython dataview处理大量数据_38个常用Python库:数值计算、可视化、机器学习等8大领域都有了...
作者 | 李明江 张良均 周东平 张尚佳 来源 | 大数据DT 原文 | 38个常用Python库:数值计算.可视化.机器学习等8大领域都有了 Python作为一个设计优秀的程序语言,现在已广泛应用于 ...
- 一个「神奇」的Python库,99%的人都爱!
背景介绍 今天介绍Python中一个超级神奇的库,99%人用过都喜欢它,剩下的1%没用过! 在如今的大数据时代,数据的价值可想而知.有时候为了做测试,需要模拟真实的环境,但是又不能直接使用真实数据,就 ...
- 2018 年最受欢迎的 Python 库,你都用过吗?
全世界只有3.14 % 的人关注了 数据与算法之美 前段时间,数据科学网站 KDnuggets 评选出了顶级 Python 库 Top15,领域横跨数据科学.数据可视化.深度学习和机器学习.推荐阅读& ...
- 都说Python库千千万,这几个你认识不?
目前,人工智能的应用日渐广泛. 而作为人工智能核心的机器学习,是一门多领域的交叉学科,专门研究计算机模拟或实现人类学习行为的方法,以获取新的知识或技能,重新组织已有的知识结构使之不断改善自身的性能. ...
- 2018年最受欢迎的Python库,你都用过吗?
AI前线导读: 近日,数据科学网站KDnuggets评选出了顶级Python库Top15,领域横跨数据科学.数据可视化.深度学习和机器学习. 和往常一样,我们需要你们的意见,如果你觉得项目没有上榜单是 ...
- win 10 pip 安装都超时_清华Anaconda 镜像恢复及一键安装气象常用的Python库
欢迎订阅微信公众号:『气象学家』 清华Anaconda 镜像恢复使用了! 阅读建议 Python的版本和环境控制建议使用conda来管理,可以预先安装Anaconda"全家桶"或者 ...
- 解决 ubuntu图形界面无法打开,全屏都是【ok】,linux磁盘空间不足,pycharm添加桌面快捷方式,pip无法安装python库,火狐无法联网
说多了都是泪啊,昨天折腾大半天终于解决了上述问题,整理一下,如果能帮助大家就更好了(ps:本人小白一枚,很多东西都不明白原理,还请大家多多指教) 1 ubuntu图形界面无法打开,全屏都是[ok] 首 ...
最新文章
- 【转载】如何学JavaScript?前辈的经验之谈
- Resource interpreted as Script but transferred with MIME type text/plain:
- [2]-使用busybox-1.17.2制作文件系统
- 我的世界手机版服务器显示即将推出,我的世界手机版领域服即将开启 什么是领域服...
- python用户名密码登录退出_用户登录登出
- aix 查看防火墙状态_Linux 7.x 防火墙amp;端口
- 【今日CV 视觉论文速览】Wed, 20 Feb 2019
- MySQL · TokuDB · rbtree block allocator
- 前世今生:蚂蚁金服自研数据库OceanBase的道路与思考
- Web应用工作原理、动态网页技术
- python之路 jQuery学习笔记
- c语言程序设计安卓,C语言编程学习app下载-C语言编程学习 安卓版v2.1.2-PC6安卓网...
- 设备\Device\Harddisk0\D 有一个不正确的区块
- Java服务器处理图片上传
- 用命令启动java我的世界_我的世界Minecraft Mod开发学习笔记 - 实现一个简单的命令Mod...
- linux 如何通过进程号找到文件路径
- Pytorch系列之——nn网络层
- loadrunner在win7破解提示:Cannot save the license information because acceses to the registry is denied的解
- 基于现有电脑和手机,“掌上看家”帮你零投入远程照料家中儿童与老人
- servlet 中的ServletConfig与servletContext