python
文章平均质量分 92
IT-过客
在技术的路上披荆斩棘
展开
-
使用Tornado+Nginx部署Django的一种尝试(转)
转自:奋斗足迹|崔玉松http://fendou.org/post/2012/06/01/tornad-nginx-django/使用Tornado+Nginx部署Django的一种尝试Tornado是一个异步web框架和服务器,所以在开发longpulling的chat之类应用非常的合适,但是其实本身也是一个高性能的http服务器,也可以作为一个WSGIServer。...原创 2013-04-22 16:01:19 · 116 阅读 · 0 评论 -
tornado中finish和write区别
直接上代码:import tornado.ioloopimport tornado.webclass MainHandler(tornado.web.RequestHandler): def get(self): self.finish("haha") self.write("Hello, world")class...原创 2013-07-22 14:02:09 · 399 阅读 · 0 评论 -
tornado学习一
1 安装从官网下载最新的tornado,(http://www.tornadoweb.org/)tar xvzf tornado-2.4.1.tar.gzcd tornado-2.4.1python setup.py buildsudo python setup.py install2 tornado模块介绍 最重要的一个模...原创 2013-01-24 10:58:20 · 75 阅读 · 0 评论 -
两个list合并成一个dict
已知 L1=['c','b','a'],L2=[1,2,3],将L1和L2合并成为L3={'a':1,'b':2,'c':3}样式解决方法:1 循环生成(这里不多说了)2 用dict和zip构造>>> L1=['c','b','a']>>> L2=[1,2,3]>>> L3=dict(zip(L1[...原创 2012-10-18 16:06:02 · 311 阅读 · 0 评论 -
pycurl连接基库处理方法
原:'PycURL/7.43.0 libcurl/7.19.7 NSS/3.12.10.0 zlib/1.2.3 libidn/1.18 libssh2/1.2.2'修改后:'PycURL/7.43.0 libcurl/7.29.0 OpenSSL/1.0.0 zlib/1.2.3 libidn/1.18'修改步骤:1 安装openssl 下载页面...原创 2017-06-20 13:11:01 · 147 阅读 · 0 评论 -
pycurl安装报错
linux下安装pycurl有时候会报错,导致不能用,下面列举两个解决办法:错误:ImportError: pycurl: libcurl link-time ssl backend (nss) is different from compile-time ssl backend (none/other)1 先卸载pycurl:pip uninstall pycu...原创 2016-06-20 17:45:02 · 184 阅读 · 0 评论 -
安装pypy5.1
centos 系统编译安装pypy5.1 过程系统自带python2.7.5,gcc4.8.5记录下centos安装pypy5.1遇到的一些软件的安装:http://pypy.readthedocs.io/en/latest/build.html#install-build-time-dependenciessudo yum install openss...原创 2017-06-20 13:11:18 · 237 阅读 · 0 评论 -
python的mysqldb封装类(转)
转自:http://blog.csdn.net/serverxp/article/details/6958459#===============================================================================# -*- coding: utf-8 -*-#MySQLdb封装类#author:pau...原创 2014-03-06 11:41:02 · 154 阅读 · 0 评论 -
centos升级python2.6到python2.7及相关库安装
下面列一下centos系统升级python到2.7以及安装相关库的步骤:1wget http://python.org/ftp/python/2.7.5/Python-2.7.5.tgz2 tar xvf Python-2.7.5.tgz3cd Python-2.7.54./configure5make all6sudo make instal...原创 2016-06-23 14:40:18 · 81 阅读 · 0 评论 -
python dict中将unicode打印显示为中文
dict内容:d ={u'status': u'BASE_ERROR', u'code': 7, u'uid': u'b660be2a-3a4d-4c40-bc1d-3c55cf7eb340', u'content': None, u'handler': u'USER', u'busiCode': u'-2', u'version': u'001', u'msg': ...原创 2017-10-26 10:25:39 · 494 阅读 · 0 评论 -
python 启动celery报错解决办法
今天由于接触新项目,安装一堆python库,而启动同步脚本时需要用到celery,下了最新的celery 3.0.11地址http://pypi.python.org/pypi/celery/安装启动报错:ValueError: Couldn't import 'celery.worker.strategy:default': 'latin-1' codec can't en...原创 2012-09-29 11:09:04 · 277 阅读 · 0 评论 -
python用mysqldb时查询缓冲问题
class DBBaseHandle: def __init__(self): try: self.conn = MySQLdb.connect(host=syn_config.mysql_server.get('host'), user=syn_config.mysql_server.get('user'), pass...原创 2014-03-06 11:31:14 · 113 阅读 · 0 评论 -
ubuntu python2.7安装mysql-python
Python连接mysql>>> import MySQLdbTraceback (most recent call last): File "<pyshell#2>", line 1, in <module> import MySQLdbImportError: No module named MySQ...原创 2012-10-31 17:07:25 · 117 阅读 · 0 评论 -
简单的python发送接收邮件
利用python发送接收邮件:#encoding=utf-8import sysimport timeimport emailimport smtplibdef send_mail(): try: handle = smtplib.SMTP('smtp.126.com',25) handle.login(...原创 2012-11-20 14:45:46 · 157 阅读 · 0 评论 -
python 安装库报gcc错
python安装库报错:error: command 'gcc' failed with exit status 1解决办法:sudo apt-get install python-dev原创 2012-11-20 15:27:50 · 137 阅读 · 0 评论 -
python dict输入顺序
最近在用python编程碰到这样的问题>>> d={}>>> d['c'] = 1>>> d2: {'c': 1}>>> d['d']=2>>> d3: {'c': 1, 'd': 2}>>> d['b']=4>>> ...原创 2012-09-24 14:56:54 · 130 阅读 · 0 评论 -
python 字符串替换
python字符串替换有两种方法:1. replace>>> s = 'the table of contents for the book lists all of the modules covered'>>> s.replace('e','2')7: 'th2 tabl2 of cont2nts for th2 book l...原创 2012-09-27 10:06:36 · 94 阅读 · 0 评论 -
python之yield学习
最近看新项目代码里有好多的yield,之前由于很少用,所以对其不慎了解,学习之。 yield就是一个生成器,也可以理解为自定义的迭代器,需要你每次调用next()或者是send()方法才能执行下去,直到碰到下一个yield。执行一个 send(msg) 会恢复 generator 的运行,然后发送的值将成为当前yield 表达式的返回值。然后 send...原创 2012-11-01 14:00:31 · 51 阅读 · 0 评论 -
mac安装python库报openssl文件找不到
在mac上安装一些python库报错,如下:SWIG/_m2crypto.i:54: Error: Unable to find 'openssl/opensslv.h' SWIG/_m2crypto.i:60: Error: Unable to find 'openssl/safestack.h' SWIG/_evp.i:12: Error: Unable t...原创 2018-07-03 10:01:32 · 1202 阅读 · 0 评论 -
win10安装python环境各种问题处理
在win10下安装了下python,运行项目碰到了各种问题,google了几十页,归总如下:1 python安装(很简单,直接装就行)地址:https://www.python.org/downloads/windows/ 找到对应版本直接装就行path设置:“此电脑”—>“属性”—>“高级系统设置”—>右下角“环境变量”—>双击“系统变量”里的...原创 2019-07-03 11:33:28 · 658 阅读 · 0 评论 -
python二分法查找
下面是一段用Python实现的二分法查找代码#encoding=utf-8import sysdef search2(a,m): low = 0 high = len(a) - 1 while low<=high: mid = (low + high)/2 midval = a[mid]...原创 2012-11-20 15:22:13 · 83 阅读 · 0 评论 -
python项目java重构各种问题
最近在搞python项目用java重构,出现了各种问题,记录如下:1 post请求失败,报csrf错误错误日志:Java代码018-07-30 10:46:51.568 ERROR 24753 — [nio-7001-exec-2] ssDeniedHandlerLoggingMethodBeforeAdvice : To access request URI [/warehouseIte...原创 2019-07-31 16:04:25 · 884 阅读 · 0 评论 -
Cannot uninstall ‘numpy‘问题解决
在安装excel处理库的时候碰到numpy报错,具体如下[IT-C02Z2CAXLVCF:temp shaolishuai$ pip install PandasDEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version o原创 2020-07-09 22:14:33 · 6204 阅读 · 4 评论