随笔分类 -  python

摘要:背景 在服务器没有安装mycli,安装的python版本不一致的情况下,想到通过pyinstaller编译出mycli的二进制文件直接运行。 pyinstaller -F /usr/bin/python3.6/bin/mycli --onefile 编译成功,然后悲剧的情况来了 Traceback 阅读全文
posted @ 2020-03-15 12:47 redstar9451 阅读(307) 评论(0) 推荐(0)
摘要:1. 当python异常时,web服务器一般会记录异常日志,比如uwsgi。如果用python自带的web server, 那么启动时要把输出重定向一下 2. 有时要把异常backtrace与普通日志记录在一起,可以在logging.xxx()函数中设置exc_info=True即可 3. 简单程序 阅读全文
posted @ 2019-10-02 17:43 redstar9451 阅读(660) 评论(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 阅读(94) 评论(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 阅读(114) 评论(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 阅读(205) 评论(0) 推荐(0)
摘要:from pysnmp.hlapi import * errorIndication, errorStatus, errorIndex, varBinds = next( getCmd(SnmpEngine(), CommunityData('public', mpModel=0), UdpTransportTarget(('192.168.... 阅读全文
posted @ 2018-12-27 14:53 redstar9451 阅读(224) 评论(0) 推荐(0)