(點選上方快速關註並設定為星標,一起學Python)
來源:蘇生不惑
segmentfault.com/a/1190000010103386
圖片處理
pip install pillow
from PIL import Image
import numpy as np
a = np.array(Image.open('test.jpg'))
b = [255,255,255] - a
im = Image.fromarray(b.astype('uint8'))
im.save('new.jpg')
Parse Redis dump.rdb
pip install rdbtools
> rdb --command json /var/redis/6379/dump.rdb
[{
"user003":{"fname":"Ron","sname":"Bumquist"},
"lizards":["Bush anole","Jackson's chameleon","Komodo dragon","Ground agama","Bearded dragon"],
"user001":{"fname":"Raoul","sname":"Duke"},
"user002":{"fname":"Gonzo","sname":"Dr"},
"user_list":["user003","user002","user001"]},{
"baloon":{"helium":"birthdays","medical":"angioplasty","weather":"meteorology"},
"armadillo":["chacoan naked-tailed","giant","Andean hairy","nine-banded","pink fairy"],
"aroma":{"pungent":"vinegar","putrid":"rotten eggs","floral":"roses"}}]
youtube-dl下載國外影片
pip install youtube-dl #直接安裝youtube-dl
pip install -U youtube-dl #安裝youtube-dl並更新
youtube-dl "http://www.youtube.com/watch?v=-wNyEUrxzFU"
asciinema錄製命令列操作
pip3 install asciinema
asciinema rec
asciinema play https://asciinema.org/a/132560