
代码记录
sdmzhu3
努力工作,好好学习享受生活,。。。。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
一个智力题的求解程序123456789这个9个数中间加2个减号1个加号等于100
原题是这样的 123456789这个9个数中间加2个减号1个加号等于100 想了觉得很难,很懒就写程序让计算机求解吧 [code="python"] def run_main(): print 'hi' a='123456789' x=['--+','-+-','+--'] s=0 import time t1=time.time...2010-03-27 22:33:00 · 1653 阅读 · 0 评论 -
python 2个html 解析器的比较 lxml.html 和 libxml2dom
lxml.html 和 libxml2dom 都很强大 libxml2dom 和 lxml.html 都是基于 libxml的python包装,性能也都没有什么差别 lxml.html 使用起来比较方便,但是api 不标准 libxml2dom 使用标准的api 用起来会比较舒服 和javascript的api一样 [code="python"] #coding:utf-8 ...2010-04-08 21:28:26 · 293 阅读 · 0 评论 -
mongodb 自增id 的解决方法
mongodb 自增id的解决方法 mongodb id autoincrement mongodb 没有自增id的解决方法 1. function insertObject(o) { x = db.myCollection; while( 1 ) { // determine next _id value to try ...2010-04-28 16:41:49 · 624 阅读 · 0 评论 -
python 打乱一个数组的简单方法
:) [code="python"]#coding:utf-8 import random def f(x,y):return random.randint(1,2)*2-3 a=range(10) print a #[0, 1, 2, 3, 4, 5, 6, 7, 8, 9] a.sort(f) print a #[3, 1, 8, 5, 2, 9, 0, 4, 6...原创 2010-05-28 15:33:02 · 411 阅读 · 0 评论 -
测试 内存映射文件 和文件随机 读写对比
[code="python"] def test_map(): ''' #make hello file dd if=/dev/zero of=hello.txt count=1024000 output: 524288000 0.557378053665 0 0.0396151542664 0 0.211034059525 0 0....2010-06-10 22:07:48 · 259 阅读 · 0 评论 -
python UnicodeEncodeError: 'ascii' codec can't encode characters 解决方法
python UnicodeEncodeError: 'ascii' codec can't encode characters 详解 新建一个test.py [code="python"]#coding:utf-8 s='nihao中国'.decode('utf-8') print type(s) print s [/code] 执行错误: Traceback (mo...2010-06-25 18:12:08 · 1061 阅读 · 0 评论