摘要: 1. 当python异常时,web服务器一般会记录异常日志,比如uwsgi。如果用python自带的web server, 那么启动时要把输出重定向一下 2. 有时要把异常backtrace与普通日志记录在一起,可以在logging.xxx()函数中设置exc_info=True即可 3. 简单程序 阅读全文
posted @ 2019-10-02 17:43 redstar9451 阅读(647) 评论(0) 推荐(0) 编辑
摘要: docker assistant #!/usr/local/bin/python3 import sh names = sh.docker("ps", "--format", '{{.Names}}') for name in names: ip = sh.docker("inspect", '-f 阅读全文
posted @ 2019-09-16 11:52 redstar9451 阅读(127) 评论(0) 推荐(0) 编辑
摘要: close(fileno(stdin)); dup2(sockfd, fileno(stdin)); close(fileno(stdout)); dup2(sockfd, fileno(stdout)); close(fileno(stderr)); dup2(sockfd, fileno(std 阅读全文
posted @ 2019-05-21 13:12 redstar9451 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 1. dir(object), return the attributes of the object 2. obj.__dict__ , return the attributes of a object 阅读全文
posted @ 2019-04-26 14:21 redstar9451 阅读(114) 评论(0) 推荐(0) 编辑
摘要: mysql comment Table comment add comment during creating table alter table comment check table moment Column comment add comment during creating table 阅读全文
posted @ 2019-04-12 17:40 redstar9451 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 1. for key in mydict == for key in mydict.keys() 2. mydict.keys(), mydict.values() 3. for (key, value) in mydict.items(): 阅读全文
posted @ 2019-04-08 19:59 redstar9451 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 1. convertion between list and tuple tuple(<list>) list(<tuple>) 2. ('aa',) means a tuple containing only one element 'aa' ('aa') means a tuple contai 阅读全文
posted @ 2019-04-08 19:57 redstar9451 阅读(106) 评论(0) 推荐(0) 编辑
摘要: Library 类别 子类 用途 mycli tool mysql 支持highlight,支持自动补全的mysql客户端 MySQL-python lib mysql used in python2, the next generation is mysqlclient, not ORM mysq 阅读全文
posted @ 2019-03-28 21:22 redstar9451 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 1. MySQL python2操作mysql的库是 MySQL-python, 这个库2014年不再更新了,the next generation is mysqlclient. mysqlclient is forked from MySQL-python, so they have the s 阅读全文
posted @ 2019-03-27 15:34 redstar9451 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 1. How to get container's IP address docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' <dockerid> 阅读全文
posted @ 2019-03-27 15:23 redstar9451 阅读(89) 评论(0) 推荐(0) 编辑