![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
代码记录
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 · 1553 阅读 · 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 · 248 阅读 · 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 · 565 阅读 · 0 评论 -
python 打乱一个数组的简单方法
:) [code="python"]#coding:utf-8import randomdef f(x,y):return random.randint(1,2)*2-3a=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 · 368 阅读 · 0 评论 -
测试 内存映射文件 和文件随机 读写对比
[code="python"]def test_map(): ''' #make hello file dd if=/dev/zero of=hello.txt count=1024000 output:5242880000.557378053665 00.0396151542664 00.211034059525 00....2010-06-10 22:07:48 · 211 阅读 · 0 评论 -
python UnicodeEncodeError: 'ascii' codec can't encode characters 解决方法
python UnicodeEncodeError: 'ascii' codec can't encode characters 详解 新建一个test.py[code="python"]#coding:utf-8s='nihao中国'.decode('utf-8')print type(s)print s[/code]执行错误:Traceback (mo...2010-06-25 18:12:08 · 992 阅读 · 0 评论