Python
Mr_老冷
Done is better than perfect.
展开
-
python request返回乱码 转码报错gbk codec cant decode byte 0xaf
由于对方服务器编码是gbk,request.get时乱码,用encode("gbk")报错'gbk' codec can't decode byte0xaf试了几种方法解决不了后面想到request可以直接设置返回值编码r = request.get(url)r.encoding = 'utf-8'乱码解决了....原创 2020-06-10 02:41:15 · 988 阅读 · 0 评论 -
服务器关机后supervisor意外报错supervisor.sock no such file/supervisor.sock refused connection/no such process
centos忘记续费关机了,supervisor托管的web服务器一直起不起来网上找了一堆教程和例子,发现都无法解决,即使修改到了/var/run下也不行,一直循环报错supervisor.sock no such filesupervisor.sock refused connectionno such process检查了conf文件也没发现哪里有写错折腾一个小时,无意...原创 2020-03-29 22:33:29 · 223 阅读 · 0 评论 -
macOSX图色自动脚本pyautogui踩坑
osx版本 10.15python3 3.6.51.安装pyautoguipython3-mpipinstallpyautogui原创 2020-03-07 00:35:03 · 1609 阅读 · 2 评论 -
python3 AttributeError: module 'string' has no attribute 'uppercase'
string.lowercasestring.uppercase均已取消使用string.ascii_upperrcasestring.ascii_lowercase替代原创 2019-06-08 02:39:53 · 3101 阅读 · 2 评论 -
python3 PIL提示TypeError: string argument expected, got 'bytes'
用BytesIO替代StringIO即可解决问题from io import BytesIOout = BytesIO()image.save(out, format='JPEG')原创 2019-06-08 02:34:50 · 2819 阅读 · 1 评论 -
基于python3.x,使用Tornado中的torndb模块操作数据库
转载自https://www.cnblogs.com/venz-seventeen/p/7818806.html目前Tornado中的torndb模块是不支持python3.x,所以需要修改部分torndb源码即可正常使用已修改文件下载网址:https://download.csdn.net/download/mr_oldcold/111901131、开发环境介绍操作系统:win1...转载 2019-05-19 18:24:49 · 762 阅读 · 0 评论 -
python列表list保留顺序去重
常规通过迭代或set方法,都无法保证去重后的顺序问题如下,我们可以通过列表的索引功能,对set结果进行序列化old_list=["a",1,"b","a","b",2,5,1]new_list=list(set(old_list))print new_list#['a', 1, 2, 'b', 5]new_list.sort(key=old_list.index)print new_list#['...原创 2018-05-15 17:17:02 · 2312 阅读 · 1 评论 -
python cmd乱码 raw_input
cmd执行python时中文乱码对于printstr = '这是一段中文'print(str.decode('utf-8'))对于raw_input函数,则需要result = raw_input('请输入一段中文: '.decode('utf-8').encode('gbk'))print(result.decode('utf-8'))...原创 2018-05-04 02:05:44 · 257 阅读 · 0 评论 -
Django 部署(nginx + uwsgi socket)
本文转载自https://code.ziqiangxuetang.com/django/django-nginx-deploy.html,仅作为个人留存备份本文主要讲解 nginx + uwsgi socket 的方式来部署 Django,比 Apache mod_wsgi 要复杂一些,但这是目前主流的方法。1. 运行开发服务器测试12cd zqxt # 进入项目 zqxt 目录python ma...转载 2018-04-06 14:05:17 · 2223 阅读 · 0 评论 -
pip install mysql-python报错 Failed building wheel for mysql-python
pip install mysql-python报错 Failed building wheel for mysql-python Running setup.py clean for mysql-pythonFailed to build mysql-pythonerror: command 'x86_64-linux-gnu-gcc' failed with exit status 1无法安装...原创 2018-04-06 06:55:28 · 3972 阅读 · 0 评论 -
django报错 'WSGIRequest' object has no attribute 'session'
最新学python的django后台用到session,报错 'WSGIRequest' object has no attribute 'session'开始以为是session问题,结果去掉session仍报类似'WSGIRequest' object has no attribute xxxx错误经测试和比对,是settings.py里MIDDLEWARE导致的问题MIDDLEWARE参数在...原创 2018-03-30 06:08:41 · 10267 阅读 · 0 评论 -
PyCharm20171025测试激活码可用http://xidea.online
选择licence server输入http://idea.imsxm.com/原创 2017-10-25 22:42:40 · 3065 阅读 · 2 评论