![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
zhangruixia0108
希望每天都有点小进步,每周一个稍大的进步,每月有个稍稍大的进步,每年有个大进步。
展开
-
sklearn raise ImportError('[joblib] Attempting to do parallel computing n_jobs > 1 windows
在windows下面运行 sklearn 中的代码,如果遇到 并行执行 n_jobs > 1 就会出现: raise ImportError(‘[joblib] Attempting to do parallel computing ’ ImportError: [joblib] Attempting to do parallel computing without protecting you原创 2016-04-28 11:01:17 · 1745 阅读 · 2 评论 -
python 写文件 包含中文 'ascii' codec can't decode byte 0xe8
解决方法: 添加 import sys reload(sys) sys.setdefaultencoding(‘utf8’)即可原创 2016-04-28 11:11:33 · 515 阅读 · 0 评论 -
python automated headers 自动生成格式化 注释文件 docstrings
http://stackoverflow.com/questions/6201302/how-to-have-automated-headers-for-python-filestemplate: /******************************************************************* * @file * * @date * @a转载 2016-05-10 15:57:29 · 399 阅读 · 0 评论 -
[django]在页面中正常显示包含html标记的内容,富文本信息显示
在我们使用django开发类似于博客这样的系统中,肯定会有一些富文本的内容,就是说在编辑的时候,可以进行加粗、字体、段落、表格等等操作。 我们会把编辑好的内容存储起来,然后在用的时候读取出来显示,但是如果直接显示,会把富文本的标记一起显示,而没有真正显示富文本的效果。 这是因为django的模板系统做了一些工作,例如,把<转换为<,把>转换为>等等,这些被转义了的符号,会直接显示在页面上转载 2016-04-21 09:49:27 · 3001 阅读 · 0 评论 -
使用 python urllib2 抓取网页时出现乱码的解决方案
http://www.zhxl.me/1409.html这里记录的是一个门外汉解决使用 urllib2 抓取网页时遇到乱码、崩溃、求助、解决和涨经验的过程。这类问题,事后看来只是个极小极小的坑,不过竟然花去很多时间,也值得记录一下。过程如下: 目标:抓取 http://sports.sina.com.cn/g/premierleague/index.shtml 代码:1 2 3 4 5转载 2016-05-05 19:24:12 · 467 阅读 · 0 评论 -
python 多线程 thread 不推荐使用(一)
不推荐使用thread线程什么时候结束完全没有控制,当主线程结束时,所有的线程都会被强制结束 如:import threadfrom time import sleepfrom time import ctimedef loop0(): print 'start loop0 at:', ctime() sleep(2) print 'end loop0 at:', ct原创 2016-05-07 10:25:10 · 1013 阅读 · 0 评论 -
python 多线程 thread 加锁(二)
thread.start_new_thread(function,args[,kwargs])函数原型,其中function参数是你将要调用的线程函数名称没有括号; args是讲传递给你的线程函数的参数,他必须是个tuple类型;而kwargs是可选的参数,如果没有参数,也一定是()import threadfrom time import sleepfrom time import ctim原创 2016-05-07 11:20:12 · 716 阅读 · 0 评论 -
python 多线程 threading (三)
thread 支持守护线程from time import ctimefrom time import sleepimport my_threaddef fib(x): sleep(0.005) if x < 2: return 1 return fib(x-2) + fib(x-1)def fac(x): sleep(0.1) if x原创 2016-05-07 13:04:01 · 464 阅读 · 0 评论 -
python 多线程 实现 生产者-消费者(四)
from time import ctimefrom time import sleepimport Queueimport randomimport my_threaddef writeQ(queue): print 'producing object for Q...' queue.put('xxx') print 'Queue size:', queue.qsi原创 2016-05-07 14:39:42 · 880 阅读 · 0 评论 -
Django 静态文件 js css 访问(一)
http://www.cnblogs.com/starof/p/4682812.htmlstarof 博客园首页新随笔联系订阅 管理 随笔 - 155 文章 - 0 评论 - 249 django静态文件配置一、django静态文件配置原理 静态文件配置就是为了让用户请求时django服务器能找到静态文件返回。首先要理解几个概念:媒体文件:用户上传的文件 静态文件:css,js,ima转载 2016-04-24 11:33:49 · 746 阅读 · 0 评论 -
Django js css 静态资源(二)超级棒
https://segmentfault.com/a/1190000000358284SegmentFault 问答文章笔记职位活动搜索 输入关键字搜索 消息注册 · 登录 home feed javascript php python java mysql ios android node.js html5 linux c++ css3 git golang转载 2016-04-24 11:35:20 · 751 阅读 · 0 评论 -
python cx_Oracle api
official website: http://cx-oracle.readthedocs.io/en/latest/module.htmloracle: callproc callfunc http://www.oracle.com/technetwork/articles/prez-stored-proc-084100.html原创 2016-06-13 12:59:24 · 550 阅读 · 0 评论 -
python django form error:module' object has no attribute '_meta'
test.pyfrom django.db import modelsfrom django.forms import ModelFormclass Book(**models.Model**): name = models.CharField(max_length=100) authors = models.ManyToManyField(Author)class BookFo原创 2016-06-13 14:48:28 · 3316 阅读 · 1 评论 -
django fastcgi window 部署 can't import flup.server.fcgi
python manage.py runfcgi host=127.0.0.1 port=8000 method=threaded 在后面加上 method=threaded 就可以了原创 2016-07-04 11:10:34 · 695 阅读 · 0 评论 -
django manage.py Unknown command: 'runfcgi'
当我们使用python django manage.py runfcgi 时,有时候会出现错误: Unknown command: ‘runfcgi’ 这是由于django版本,在1.9以上不支持runfcgi命令,如果要使用 runfcgi,将django的版本 更换到 1.8 就可以了原创 2016-04-07 13:11:17 · 5008 阅读 · 0 评论 -
cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
上述问题解决: copy instent client下所有的.dll文件到python安装包的lib/sit_pageages原创 2016-02-24 19:18:33 · 1417 阅读 · 0 评论 -
Python oracle ImportError: DLL load failed: 找不到指定的程序 or dll load failed 不是有效的 win32 应用程序。
安装cx_Oracle的步骤: 1. 查看自己的oracle的版本和位数,如我的是 11g,64bits我的python是2.7版本的,就需要下载这个 2. 双击进行安装可能会报错 ImportError: DLL load failed: 找不到指定的程序需要到oracle下载instant client (一定要下载对应位数的Instant Client (你的电脑的bits))原创 2016-02-19 11:34:35 · 898 阅读 · 0 评论 -
python 简单工厂模式
python 工厂模式原创 2015-11-04 16:21:22 · 308 阅读 · 0 评论 -
python json path xpath
def jsonPathVerify(self): content = self.responseContent dictmy = json.loads(content) dictmy = {"code":200,"data":{"content":[{ "code":"108862035747471360",原创 2015-11-04 20:08:22 · 566 阅读 · 0 评论 -
python mongodb 查找find()
查找全部:db.collectionName.find()根据字段查找(精确匹配,大小写敏感):db.collectionName.find( { "cuisine": "Italian"} )或的关系:db.restaurants.find( { $or: [ { "cuisine": "Italian" }, { "address.zipcode": "10075原创 2015-11-14 16:58:22 · 4597 阅读 · 0 评论 -
SONPath - XPath for JSON
http://goessner.net/articles/JsonPath/A frequently emphasized advantage of XML is the availability of plenty tools to analyse, transform and selectively extract data out of XML documents. XPath is one转载 2016-01-19 14:32:09 · 558 阅读 · 0 评论 -
python 多线程 thread
import threaddef loop0(): print "loop0 start at:",ctime() sleep(4) print "loop0 end at:",ctime()def loop1(): print "loop1 start at:",ctime() sleep(2) print "loop1 end at:",ctim转载 2016-01-20 18:19:37 · 225 阅读 · 0 评论 -
python threading join
encoding=utf-8from time import sleep,ctime import threadingloops = [6,2]def loop(nloop,nsec): print “loop “,nloop,” start at:”,ctime() sleep(nsec) print “loop “,nloop,” runing at:”,ctim原创 2016-01-21 09:58:10 · 276 阅读 · 0 评论 -
python oracle 操作
下载cx_oracle(根据自己oracle的版本,11g或者是12c),安装 参考资料: http://www.oracle.com/technetwork/articles/dsl/prez-python-queries-101587.html http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/oow10/python原创 2016-01-22 14:37:15 · 408 阅读 · 0 评论 -
python list解析, map,生成器表达式
def inc(x): return x+10L = [1,2,3,4]print map(inc,L)print map((lambda x: x+10),L)def add(x,y): return x+ylist1 = [11,22,33]list2 = [44,55,66]print map(add,list1,list2)输出: [11, 12, 13, 14]转载 2016-01-25 10:59:23 · 1508 阅读 · 0 评论 -
python UI自动化 splinter
下载zip文件 到 splinter 文件夹下面 python setup.py install 官网: http://splinter.readthedocs.org/en/latest/finding.htmlfrom splinter import Browserbrowser = Browser()browser.visit('https://www.baidu.com/')brow原创 2016-01-25 18:15:21 · 293 阅读 · 0 评论 -
Python动态加载模块的3种方法
转载 http://www.jb51.net/article/57694.htm 1、使用系统函数_import()stringmodule = import(‘string’) 2、使用imp 模块import imp stringmodule = imp.load_module(‘string’,*imp.find_module(‘string’)) 3、使用execimport_st转载 2016-01-25 19:05:22 · 777 阅读 · 0 评论 -
python 正则表达式
在python中re模块支持正则表达式,主要的方法有: search() match() findall() compile() sub() subn() group() groups() split()complile 预编译正则表达式,编译调用的是方法,不编译,使用函数,但是名字都是相同的,如: reg = r’(\d+)-(\d{3})-(\w+)’ pattern原创 2016-01-27 11:05:04 · 226 阅读 · 0 评论 -
python Exception
python 常见的异常:NameErrorZeroDivisionErrorSyntaxErrorIndex ErrorKeyErrorAttributeErrorValueErrorIOErrorTypeError 捕获异常:try: Aexcept (Exception1, Exception2),e: print str(e)except (Excep原创 2016-01-29 11:26:57 · 362 阅读 · 0 评论 -
python 命令行参数
import sysprint 'argc:'print len(sys.argv)print "argv:"print sys.argv结果: D:>python testargv.py ahishis hshishi shdhihi argc: 4 argv: [‘testargv.py’, ‘ahishis’, ‘hshishi’, ‘shdhihi’]原创 2016-02-01 10:39:56 · 403 阅读 · 0 评论 -
python Custom template tags and filters is not a valid tag library
http://stackoverflow.com/questions/8607544/django-could-not-load-template-tag/21588173#21588173suppose you have the following structure:– Application_Name——-templatetags————–init.py————–templates_extra转载 2016-03-16 19:00:57 · 424 阅读 · 0 评论 -
python 9种部署方法
http://www.jb51.net/article/51645.htm转载 2016-07-05 09:51:44 · 791 阅读 · 0 评论