Python

     摘要: Python的标准库中的os模块包含普遍的操作系统功能。如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的。即它允许一个程序在编写后不需要任何改动,也不会发生任何问题,就可以在Linux和Windows下运行。下面列出了一些在os模块中比较有用的部分。它们中的大多数都简单明了。os.sep 可以取代操作系统特定的路径分割符。 os.name字符串指示你正在使用的平台。比如对于Windows...  阅读全文
posted @ 2010-08-04 13:08 finallyliuyu 阅读(26) | 评论 (0) 编辑
     摘要: >>> a.append(('a',1))>>> a.append(('b',20))>>>a.append(('c',-200))>>> a.sort(key=lambda d:d[1],reverse=True)>>> a[('b', 20), ('a', 1), ('c', -200)]  阅读全文
posted @ 2010-08-03 14:51 finallyliuyu 阅读(25) | 评论 (0) 编辑
     摘要: 1.想实现对一个二类文本问题的两种分类方法,首先要对文档集合的文本进行分词,然后建立倒排表,倒排表是借助于mysql数据库的,但是有一个众所周知的事情,mysql插入汉字会出现各种莫名奇妙的情况,首当其冲是插不进去,而获是插进去了,但是显示是乱码,然后将插入后的数据再读到程序中仍然是乱码。这归根结底是编码符号不一致的问题也就是。再解决这个问题的过程中,我参考了http://www.busfly.c...  阅读全文
posted @ 2010-05-14 21:52 finallyliuyu 阅读(878) | 评论 (7) 编辑
     摘要: 遍历字典for m in mydict.iteritems(): print m  阅读全文
posted @ 2010-04-24 11:26 finallyliuyu 阅读(94) | 评论 (0) 编辑
     摘要: 1.论文 Python 与 Matlab混合语言编程 作者 董焰民,王保保2.需要下载相应版本的pywin32资料下载https://files.cnblogs.com/finallyliuyu/pythonmatlabmixcoding.rar2.python调用M文件mport osdatafile=file(r'f.dat')s=datafile.read()import dictformat...  阅读全文
posted @ 2010-04-15 17:15 finallyliuyu 阅读(68) | 评论 (0) 编辑
     摘要: 备份1:一个专搞python mysql链接的人的博客 http://hi.baidu.com/jackbillow/blog/item/ae29e36ecaea96dd80cb4a56.html资料下载地址https://files.cnblogs.com/finallyliuyu/pythonmysql.rar建议大家先将资料中的两个dll文件拷贝到c:\windows\system32下面,然...  阅读全文
posted @ 2010-04-15 12:57 finallyliuyu 阅读(27) | 评论 (0) 编辑
     摘要: [Python学习]Iterator 和 Generator的学习心得Iterator是迭代器的意思,它的作用是一次产生一个数据项,直到没有为止。这样在 for 循环中就可以对它进行循环处理了。那么它与一般的序列类型(list, tuple等)有什么区别呢?它一次只返回一个数据项,占用更少的内存。但它需要记住当前的状态,以便返回下一数据项。它是一个有着next()方法的对象。而序列类型则保存了所有...  阅读全文
posted @ 2010-04-09 20:19 finallyliuyu 阅读(52) | 评论 (0) 编辑
     摘要: 最近打算用Python做分词,在生成字典的时候,我采用的方法是逐个元素处理的方法,结果由于训练语料中的数据量过大,这样处理很慢。所以打算学学迭代器与生成器,看看能不能对序列进行批量处理(这点和matlab有点像)以下内容转载自:http://blog.csdn.net/chszs/archive/2009/01/24/3852669.aspx 把美文自己索罗到博客中来,我的博客就可以成为一个小的资...  阅读全文
posted @ 2010-04-09 19:41 finallyliuyu 阅读(43) | 评论 (0) 编辑
     摘要: 集合 http://www.lupaworld.com/18733/viewspace_39491.html 正则Python debug(来源http://linhs.blog.51cto.com/370259/125323)文讨论在没有方便的IDE工具可用的情况下,使用pdb调试python程序 源码例子例如,有模拟税收计算的程序:#!/usr/bin/python def debug_dem...  阅读全文
posted @ 2010-04-09 16:40 finallyliuyu 阅读(23) | 评论 (0) 编辑
     摘要: 资料见:http://en.wikipedia.org/wiki/Viterbi_algorithm代码如下C:Python26MyViterbiMyViterbi.pyCode highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#-*-coding:cp936-...  阅读全文
posted @ 2010-04-07 09:30 finallyliuyu 阅读(69) | 评论 (0) 编辑
     摘要: 1.<beautiful data>中的例子,由于没有中文语料库,故用英文串代替,思路一样(如将finallyaurora)切分成['finally','aurora']2.代码切分模块代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->i...  阅读全文
posted @ 2010-04-07 09:23 finallyliuyu 阅读(116) | 评论 (1) 编辑
     摘要: http://nltk.googlecode.com/svn/trunk/doc/api/nltk-module.html http://www.tau.ac.il/~kineret/amit/scipy_tutorial/ scipy 的使用说明2)主程序所在目录是模块所在目录的父(或祖辈)目录如下面程序结构:`-- src |-- mod1.py |-- mod2 | `-- mod2.py ...  阅读全文
posted @ 2010-04-04 16:50 finallyliuyu 阅读(93) | 评论 (1
原文地址:https://www.cnblogs.com/Leo_wl/p/1820487.html