Change Pip Conf in Global

Change pip conf in global 1cat >> .pip/pip.conf << EOF 23[global] 45timeout = 6000 67index-url = https://pypi.douban.com/simple/ 89[install] 1011use-mirrors = true 1213mirrors = https://pypi.douban.com/simple/ 1415trusted-host = pypi.douban.com 1617EOF

Fxxk SSH

Fxxk SSH 1 curl -O -L https://sourceforge.net/projects/sshpass/files/sshpass/1.06/sshpass-1.06.tar.gz && tar xvzf sshpass-1.06.tar.gz 2 ./configure 3 make install

CPython

CPython FFmpeg calls python Depends ffmpeg needs to dynamically compile (or python programs need to be statically compiled, it’s difficult) python program needs to call cpython interface Example docker images python programs debug

Zip Picture With Python

Zip Picture With Python 1from PIL import Image 2import sys 3def gipit(pname): 4 with Image.open(pname) as im: 5 im.save(pname+'.jpeg', 'jpeg', progressive=True, optimize=True) 6if __name__ == '__main__': 7 _, pname = sys.argv 8 gipit(pname)

Flask Logger

Flask Logger Flask logging 使用 Flask 时,如何优雅的输出日志。这些日志也许需要特定的格式,更丰富的信息,或者添加一些上下文的信息(如当前登录的用户名)等等。 根据官方文档

Code Template

Code template Code Template Python多进程写入文件(multiprocessing template) 参考文档 1#multiprocessing template 2import multiprocessing 3 4def write_file(result): 5 f = open('') 6 f.write(result) 7 8def process(args): 9 ''' 10work 11''' 12 return result 13 14if __name__ == '__main__': 15 pool = …

Python Exec Object

Python Exec Object exec() Syntax: 1exec(object[, globals[, locals]]) 2 3:param object: As already said this can be a string or object code 4:param globals: This can be a dictionary and the parameter is optional 5:param locals: This can be a mapping object and is also optional eg. 1from math import * 2exec("print(factorial(5))", …