成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

那些有趣/用的Python庫

開發 后端
本文介紹一些有趣、有用的Python庫,其中包括圖片處理、youtube-dl下載國外視頻、查看對象的全部屬性和方法等。

圖片處理

  1. pip install pillow 
  2.  
  3. from PIL import Image 
  4.  
  5. import numpy as np 
  6.  
  7. a = np.array(Image.open('test.jpg')) 
  8.  
  9. b = [255,255,255] - a 
  10.  
  11. im = Image.fromarray(b.astype('uint8')) 
  12.  
  13. im.save('new.jpg' 

youtube-dl下載國外視頻

  1. pip install youtube-dl #直接安裝youtube-dl 
  2.  
  3. pip install -U youtube-dl #安裝youtube-dl并更新 
  4.  
  5. youtube-dl "http://www.youtube.com/watch?v=-wNyEUrxzFU"  

查看對象的全部屬性和方法

  1. pip install pdir2 
  2.  
  3. >>> import pdir,requests 
  4.  
  5. >>> pdir(requests) 
  6.  
  7. module attribute: 
  8.  
  9.     __cached__, __file__, __loader__, __name__, __package__, __path__, __spec__ 
  10.  
  11. other: 
  12.  
  13.     __author__, __build__, __builtins__, __copyright__, __license__, __title__, 
  14.  
  15. __version__, _internal_utils, adapters, api, auth, certs, codes, compat, cookies 
  16.  
  17. , exceptions, hooks, logging, models, packages, pyopenssl, sessions, status_code 
  18.  
  19. s, structures, utils, warnings 
  20.  
  21. special attribute: 
  22.  
  23.     __doc__ 
  24.  
  25. class: 
  26.  
  27.     NullHandler: This handler does nothing. It's intended to be used to avoid th 
  28.  
  29.  
  30.     PreparedRequest: The fully mutable :class:`PreparedRequest <PreparedRequest> 
  31.  
  32. ` object, 
  33.  
  34.     Request: A user-created :class:`Request <Request>` object. 
  35.  
  36.     Response: The :class:`Response <Response>` object, which contains a 
  37.  
  38.     Session: A Requests session. 
  39.  
  40. exception: 
  41.  
  42.     ConnectTimeout: The request timed out while trying to connect to the remote 
  43.  
  44. server. 
  45.  
  46.     ConnectionError: A Connection error occurred. 
  47.  
  48.     DependencyWarning: Warned when an attempt is made to import a module with mi 
  49.  
  50. ssing optional 
  51.  
  52.     FileModeWarning: A file was opened in text mode, but Requests determined its 
  53.  
  54. binary length. 
  55.  
  56.     HTTPError: An HTTP error occurred. 
  57.  
  58.     ReadTimeout: The server did not send any data in the allotted amount of time 
  59.  
  60.  
  61.     RequestException: There was an ambiguous exception that occurred while handl 
  62.  
  63. ing your 
  64.  
  65.     Timeout: The request timed out
  66.  
  67.     TooManyRedirects: Too many redirects. 
  68.  
  69.     URLRequired: A valid URL is required to make a request. 
  70.  
  71. function
  72.  
  73.     delete: Sends a DELETE request. 
  74.  
  75.     get: Sends a GET request. 
  76.  
  77.     head: Sends a HEAD request. 
  78.  
  79.     options: Sends a OPTIONS request. 
  80.  
  81.     patch: Sends a PATCH request. 
  82.  
  83.     post: Sends a POST request. 
  84.  
  85.     put: Sends a PUT request. 
  86.  
  87.     request: Constructs and sends a :class:`Request <Request>`. 
  88.  
  89.     session: Returns a :class:`Session` for context-management.  

Python 玩轉網易云音樂

  1. pip install ncmbot 
  2.  
  3. import ncmbot 
  4.  
  5. #登錄 
  6.  
  7. bot = ncmbot.login(phone='xxx'password='yyy'
  8.  
  9. bot.content # bot.json() 
  10.  
  11. #獲取用戶歌單 
  12.  
  13. ncmbot.user_play_list(uid='36554272' 

下載視頻字幕

  1. pip install getsub 

 

Python 財經數據接口包

  1. pip install tushare 
  2.  
  3. import tushare as ts 
  4.  
  5. #一次性獲取最近一個日交易日所有股票的交易數據 
  6.  
  7. ts.get_today_all() 
  8.  
  9.   
  10.  
  11. 代碼,名稱,漲跌幅,現價,開盤價,最高價,最低價,最日收盤價,成交量,換手率 
  12.  
  13.       code    name     changepercent  trade   open   high    low  settlement \   
  14.  
  15. 0     002738  中礦資源         10.023  19.32  19.32  19.32  19.32       17.56   
  16.  
  17. 1     300410  正業科技         10.022  25.03  25.03  25.03  25.03       22.75   
  18.  
  19. 2     002736  國信證券         10.013  16.37  16.37  16.37  16.37       14.88   
  20.  
  21. 3     300412  迦南科技         10.010  31.54  31.54  31.54  31.54       28.67   
  22.  
  23. 4     300411  金盾股份         10.007  29.68  29.68  29.68  29.68       26.98   
  24.  
  25. 5     603636  南威軟件         10.006  38.15  38.15  38.15  38.15       34.68   
  26.  
  27. 6     002664  信質電機         10.004  30.68  29.00  30.68  28.30       27.89   
  28.  
  29. 7     300367  東方網力         10.004  86.76  78.00  86.76  77.87       78.87   
  30.  
  31. 8     601299  中國北車         10.000  11.44  11.44  11.44  11.29       10.40   
  32.  
  33. 9     601880   大連港         10.000   5.72   5.34   5.72   5.22        5.20   
  34.  
  35. 10    000856  冀東裝備         10.000   8.91   8.18   8.91   8.18        8.10  

開源漏洞靶場

  1. # 安裝pip 
  2.  
  3. curl -s https://bootstrap.pypa.io/get-pip.py | python3 
  4.  
  5.   
  6.  
  7. # 安裝docker 
  8.  
  9. apt-get update && apt-get install docker.io 
  10.  
  11.   
  12.  
  13. # 啟動docker服務 
  14.  
  15. service docker start 
  16.  
  17.   
  18.  
  19. # 安裝compose 
  20.  
  21. pip install docker-compose 
  22.  
  23. # 拉取項目 
  24.  
  25. git clone git@github.com:phith0n/vulhub.git 
  26.  
  27. cd vulhub 
  28.  
  29.   
  30.  
  31. # 進入某一個漏洞/環境的目錄 
  32.  
  33. cd nginx_php5_mysql 
  34.  
  35.   
  36.  
  37. # 自動化編譯環境 
  38.  
  39. docker-compose build 
  40.  
  41.   
  42.  
  43. # 啟動整個環境 
  44.  
  45. docker-compose up -d 
  46.  
  47. #測試完成后,刪除整個環境 
  48.  
  49. docker-compose down  

北京實時公交

  1. pip install -r requirements.txt 安裝依賴 
  2.  
  3. python manage.py build_cache 獲取離線數據,建立本地緩存 
  4.  
  5. #項目自帶了一個終端中的查詢工具作為例子,運行: python manage.py cli 
  6.  
  7. >>> from beijing_bus import BeijingBus 
  8.  
  9. >>> lines = BeijingBus.get_all_lines() 
  10.  
  11. >>> lines 
  12.  
  13. [<Line: 運通122(農業展覽館-華紡易城公交場站)>, <Line: 運通101(廣順南大街北口-藍龍家園)>, ...] 
  14.  
  15. >>> lines = BeijingBus.search_lines('847'
  16.  
  17. >>> lines 
  18.  
  19. [<Line: 847(馬甸橋西-雷莊村)>, <Line: 847(雷莊村-馬甸橋西)>] 
  20.  
  21. >>> line = lines[0] 
  22.  
  23. >>> print line.id, line.name 
  24.  
  25. 541 847(馬甸橋西-雷莊村) 
  26.  
  27. >>> line.stations 
  28.  
  29. [<Station 馬甸橋西>, <Station 馬甸橋東>, <Station 安華橋西>, ...] 
  30.  
  31. >>> station = line.stations[0] 
  32.  
  33. >>> print station.name, station.lat, station.lon 
  34.  
  35. 馬甸橋西 39.967721 116.372921 
  36.  
  37. >>> line.get_realtime_data(1) # 參數為站點的序號,從1開始 
  38.  
  39.  
  40.     { 
  41.  
  42.         'id': 公交車id, 
  43.  
  44.         'lat': 公交車的位置, 
  45.  
  46.         'lon': 公交車位置, 
  47.  
  48.         'next_station_name': 下一站的名字, 
  49.  
  50.         'next_station_num': 下一站的序號, 
  51.  
  52.         'next_station_distance': 離下一站的距離, 
  53.  
  54.         'next_station_arriving_time': 預計到達下一站的時間, 
  55.  
  56.         'station_distance': 離本站的距離, 
  57.  
  58.         'station_arriving_time': 預計到達本站的時間, 
  59.  
  60.     }, 
  61.  
  62.     ... 
  63.  
  64.  

文章提取器

  1. git clone https://github.com/grangier/python-goose.git 
  2.  
  3. cd python-goose 
  4.  
  5. pip install -r requirements.txt 
  6.  
  7. python setup.py install 
  8.  
  9.   
  10.  
  11. >>> from goose import Goose 
  12.  
  13. >>> from goose.text import StopWordsChinese 
  14.  
  15. >>> url  = 'http://www.bbc.co.uk/zhongwen/simp/chinese_news/2012/12/121210_hongkong_politics.shtml' 
  16.  
  17. >>> g = Goose({'stopwords_class': StopWordsChinese}) 
  18.  
  19. >>> article = g.extract(url=url) 
  20.  
  21. >>> print article.cleaned_text[:150]  

香港行政長官梁振英在各方壓力下就其大宅的違章建筑(僭建)問題到立法會接受質詢,并向香港民眾道歉。

梁振英在星期二(12月10日)的答問大會開始之際在其演說中道歉,但強調他在違章建筑問題上沒有隱瞞的意圖和動機。

一些親北京陣營議員歡迎梁振英道歉,且認為應能獲得香港民眾接受,但這些議員也質問梁振英有

Python 藝術二維碼生成器

  1. pip install MyQR 
  2.  
  3. myqr https://github.com 
  4.  
  5. myqr https://github.com -v 10 -l Q 

 

 

偽裝瀏覽器身份

  1. pip install fake-useragent 
  2.  
  3. from fake_useragent import UserAgent 
  4.  
  5. ua = UserAgent() 
  6.  
  7.   
  8.  
  9. ua.ie 
  10.  
  11. # Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US); 
  12.  
  13. ua.msie 
  14.  
  15. # Mozilla/5.0 (compatible; MSIE 10.0; Macintosh; Intel Mac OS X 10_7_3; Trident/6.0)' 
  16.  
  17. ua['Internet Explorer'
  18.  
  19. # 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) 
  20.  
  21. ua.opera 
  22.  
  23. # Opera/9.80 (X11; Linux i686; U; ru) Presto/2.8.131 Version/11.11 
  24.  
  25. ua.chrome 
  26.  
  27. # Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.2 (KHTML, like Gecko) Chrome/22.0.1216.0 Safari/537.2'  

美化 curl

  1. pip install httpstat 
  2.  
  3. httpstat httpbin.org/get 

 

  1. python shell 
  2.  
  3. pip install sh 
  4.  
  5. from sh import ifconfig 
  6.  
  7. print ifconfig("eth0" 

處理中文文本內容

  1. pip install -U textblob#英文文本的情感分析 
  2.  
  3. pip install snownlp#中文文本的情感分析 
  4.  
  5. from snownlp import SnowNLP 
  6.  
  7. text = "I am happy today. I feel sad today." 
  8.  
  9. from textblob import TextBlob 
  10.  
  11. blob = TextBlob(text) 
  12.  
  13. TextBlob("I am happy today. I feel sad today."
  14.  
  15. blob.sentiment 
  16.  
  17. Sentiment(polarity=0.15000000000000002, subjectivity=1.0) 
  18.  
  19.   
  20.  
  21.   
  22.  
  23. s = SnowNLP(u'這個東西真心很贊'
  24.  
  25.   
  26.  
  27. s.words         # [u'這個', u'東西', u'真心'
  28.  
  29.                 #  u'很', u'贊'
  30.  
  31.   
  32.  
  33. s.tags          # [(u'這個', u'r'), (u'東西', u'n'), 
  34.  
  35.                 #  (u'真心', u'd'), (u'很', u'd'), 
  36.  
  37.                 #  (u'贊', u'Vg')] 
  38.  
  39.   
  40.  
  41. s.sentiments    # 0.9769663402895832 positive的概率 
  42.  
  43.   
  44.  
  45. s.pinyin        # [u'zhe', u'ge', u'dong', u'xi'
  46.  
  47.                 #  u'zhen', u'xin', u'hen', u'zan'
  48.  
  49.   
  50.  
  51. s = SnowNLP(u'「繁體字」「繁體中文」的叫法在臺灣亦很常見。'
  52.  
  53.   
  54.  
  55. s.han           # u'「繁體字」「繁體中文」的叫法 
  56.  
  57.                 # 在臺灣亦很常見。  

抓取發放代理

  1. pip install -U getproxy 
  2.  
  3. ➜ ~ getproxy --help 
  4.  
  5. Usage: getproxy [OPTIONS] 
  6.  
  7.   
  8.  
  9. Options: 
  10.  
  11. --in-proxy TEXT Input proxy file 
  12.  
  13. --out-proxy TEXT Output proxy file 
  14.  
  15. --help Show this message and exit. 
  • --in-proxy 可選參數,待驗證的 proxies 列表文件
  • --out-proxy 可選參數,輸出已驗證的 proxies 列表文件,如果為空,則直接輸出到終端
  • --in-proxy 文件格式和 --out-proxy 文件格式一致

zhihu api

  1. pip install git+git://github.com/lzjun567/zhihu-api --upgrade 
  2.  
  3. from zhihu import Zhihu 
  4.  
  5. zhihu = Zhihu() 
  6.  
  7. zhihu.user(user_slug="xiaoxiaodouzi"
  8.  
  9.   
  10.  
  11. {'avatar_url_template''https://pic1.zhimg.com/v2-ca13758626bd7367febde704c66249ec_{size}.jpg'
  12.  
  13.      'badge': [], 
  14.  
  15.      'name''我是小號'
  16.  
  17.      'headline''程序員'
  18.  
  19.      'gender': -1, 
  20.  
  21.      'user_type''people'
  22.  
  23.      'is_advertiser'False
  24.  
  25.      'avatar_url''https://pic1.zhimg.com/v2-ca13758626bd7367febde704c66249ec_is.jpg'
  26.  
  27.      'url''http://www.zhihu.com/api/v4/people/1da75b85900e00adb072e91c56fd9149''type''people'
  28.  
  29.      'url_token''xiaoxiaodouzi'
  30.  
  31.      'id''1da75b85900e00adb072e91c56fd9149'
  32.  
  33.      'is_org'False

 

解析 nginx 訪問日志并格式化輸出

  1. pip install ngxtop 
  2.  
  3. $ ngxtop 
  4.  
  5. running for 411 seconds, 64332 records processed: 156.60 req/sec 
  6.  
  7.   
  8.  
  9. Summary: 
  10.  
  11. |   count |   avg_bytes_sent |   2xx |   3xx |   4xx |   5xx | 
  12.  
  13. |---------+------------------+-------+-------+-------+-------| 
  14.  
  15. |   64332 |         2775.251 | 61262 |  2994 |    71 |     5 | 
  16.  
  17.   
  18.  
  19. Detailed: 
  20.  
  21. | request_path                             |   count |   avg_bytes_sent |   2xx |   3xx |   4xx |   5xx | 
  22.  
  23. |------------------------------------------+---------+------------------+-------+-------+-------+-------| 
  24.  
  25. | /abc/xyz/xxxx                            |   20946 |          434.693 | 20935 |     0 |    11 |     0 | 
  26.  
  27. | /xxxxx.json                              |    5633 |         1483.723 |  5633 |     0 |     0 |     0 | 
  28.  
  29. | /xxxxx/xxx/xxxxxxxxxxxxx                 |    3629 |         6835.499 |  3626 |     0 |     3 |     0 | 
  30.  
  31. | /xxxxx/xxx/xxxxxxxx                      |    3627 |        15971.885 |  3623 |     0 |     4 |     0 | 
  32.  
  33. | /xxxxx/xxx/xxxxxxx                       |    3624 |         7830.236 |  3621 |     0 |     3 |     0 | 
  34.  
  35. | /static/js/minified/utils.min.js         |    3031 |         1781.155 |  2104 |   927 |     0 |     0 | 
  36.  
  37. | /static/js/minified/xxxxxxx.min.v1.js    |    2889 |         2210.235 |  2068 |   821 |     0 |     0 | 
  38.  
  39. | /static/tracking/js/xxxxxxxx.js          |    2594 |         1325.681 |  1927 |   667 |     0 |     0 | 
  40.  
  41. | /xxxxx/xxx.html                          |    2521 |          573.597 |  2520 |     0 |     1 |     0 | 
  42.  
  43. | /xxxxx/xxxx.json                         |    1840 |          800.542 |  1839 |     0 |     1 |     0 |  

火車余票查詢

  1. pip install iquery  
  2. Usage: 
  3.  
  4.         iquery (-c|彩票) 
  5.  
  6.         iquery (-m|電影) 
  7.  
  8.         iquery -p <city> 
  9.  
  10.         iquery -l song [singer] 
  11.  
  12.         iquery -p <city> <hospital> 
  13.  
  14.         iquery <city> <show> [<days>] 
  15.  
  16.         iquery [-dgktz] <from> <to> <date
  17.  
  18.   
  19.  
  20.     Arguments: 
  21.  
  22.         from             出發站 
  23.  
  24.         to               到達站 
  25.  
  26.         date             查詢日期 
  27.  
  28.   
  29.  
  30.         city             查詢城市 
  31.  
  32.         show             演出的類型 
  33.  
  34.         days             查詢近(幾)天內的演出, 若省略, 默認15 
  35.  
  36.   
  37.  
  38.         city             城市名,加在-p后查詢該城市所有莆田醫院 
  39.  
  40.         hospital         醫院名,加在city后檢查該醫院是否是莆田系 
  41.  
  42.   
  43.  
  44.   
  45.  
  46.     Options: 
  47.  
  48.         -h, --help       顯示該幫助菜單. 
  49.  
  50.         -dgktz           動車,高鐵,快速,特快,直達 
  51.  
  52.         -m               熱映電影查詢 
  53.  
  54.         -p               莆田系醫院查詢 
  55.  
  56.         -l               歌詞查詢 
  57.  
  58.         -c               彩票查詢 
  59.  
  60.   
  61.  
  62.     Show: 
  63.  
  64.         演唱會 音樂會 音樂劇 歌舞劇 兒童劇 話劇 
  65.  
  66.         歌劇 比賽 舞蹈 戲曲 相聲 雜技 馬戲 魔術  
責任編輯:龐桂玉 來源: Python開發者
相關推薦

2022-12-28 08:59:11

2010-04-09 11:07:40

Oracle 有趣排序

2011-06-13 10:30:07

Linus Torva

2020-07-13 07:27:16

Python開發

2022-06-30 09:00:23

Vue.js版本名稱

2013-01-14 10:23:32

2022-03-31 11:56:34

Android 12智能手機功能

2022-08-23 12:32:37

Python可視化圖表

2018-09-08 17:45:26

2021-07-13 10:59:49

Python可視化

2012-02-20 10:14:37

科技記者軟件

2020-07-29 10:00:38

PythonEllipsis索引

2022-10-10 23:19:02

Python腳本語言工具庫

2016-12-05 15:15:52

JavaScriptCSS庫

2020-05-28 13:11:37

Python編碼 開發

2020-03-29 20:27:51

Python函數開發

2022-01-23 14:08:52

PythonPygame

2018-11-30 18:30:17

數據庫運維機器學習

2024-02-21 10:24:37

IOT物聯網AR

2019-10-31 08:59:23

Python工具萬圣節
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 男女视频在线观看 | 国产在线成人 | 久久国产精品一区二区三区 | 日韩一级欧美一级 | 6996成人影院网在线播放 | 国产一区不卡 | 欧美亚洲另类丝袜综合网动图 | 噜啊噜在线 | 精品三区| 日韩一区二区在线视频 | 亚洲色欧美另类 | 久草在线青青草 | 亚洲欧美国产精品一区二区 | 日韩一级 | 国产免费又黄又爽又刺激蜜月al | 色先锋影音 | 国产精品视频yy9299一区 | 亚洲第一视频网站 | 国产高清精品一区二区三区 | 欧美日韩视频 | 国产视频黄色 | 欧美视频免费在线观看 | 精品成人在线视频 | 欧美不卡在线 | 91tv在线观看 | 色久五月| 亚洲精品视频在线看 | 99re在线视频免费观看 | 能看的av网站 | 国产成人黄色 | 成人免费xxxxx在线视频 | 在线观看视频一区 | 免费成人高清在线视频 | 国产主播第一页 | 91看片免费版 | 高清18麻豆 | 狠狠操电影 | 日韩中出| 91精品国产综合久久久久久蜜臀 | 特级黄一级播放 | 91精品国产一区二区在线观看 |