随笔分类 -  Python

摘要:1. 用word_tokenize的时候说 u'tokenizers/punkt/english.pickle' not found. 我nltk.download(),想把所有的corpus下下来,但经常断。于是手动在网站上把corpora下下来,但还是说不对。 其实只要nltk.download 阅读全文
posted @ 2016-05-12 17:09 白天黑夜每日c 阅读(183) 评论(0) 推荐(0)
摘要:在用http://muricoca.github.io/crab/tutorial.html 里给的例子时,会发现不能运行,改库里的两个小地方就好了。 1. no module named learn: 把scikit.base里的from scikit.learn.base改成from sklea 阅读全文
posted @ 2016-05-02 17:30 白天黑夜每日c 阅读(312) 评论(0) 推荐(0)
摘要:python文本分析用到scikit-learn包,用pip安装:pip install -U scikit-learn 阅读全文
posted @ 2016-04-13 19:47 白天黑夜每日c 阅读(110) 评论(0) 推荐(0)
摘要:把.csv文件导入mysql,.csv文件以','分隔,在每一项字符串中含有',' 不能用load data local infile .. fields terminated by ',',否则字符串被截断。 用re 阅读全文
posted @ 2016-04-13 17:57 白天黑夜每日c 阅读(804) 评论(0) 推荐(0)
摘要:之前装过beautifulsoup,这次要装lxml,用easy_install装:到python/scripts目录下,运行easy_install lxml,自动安装 分界线 之前直接用urlopen(url),拒绝访问,403forbidden 模仿真实上网,添加cookie (转自http: 阅读全文
posted @ 2016-04-08 19:49 白天黑夜每日c 阅读(315) 评论(0) 推荐(0)
摘要:import mysql.connector 在命令行里运行python脚本,显示没有mysql.connector cnx = mysql.connector(user =' ', password=' ',host =' ', database =' ') cnx.close() cursor 阅读全文
posted @ 2016-04-05 15:27 白天黑夜每日c 阅读(171) 评论(0) 推荐(0)
摘要:1. python读取文件时的路径,明明是放在一个文件夹里,怎么不完整路径会错 2. file.write(str1+str2)用+拼接,不能用, 3. open()用法: 4. 在用r+模式读写文件时,写之前要file.seek(文件位置),不然无法写。 阅读全文
posted @ 2016-03-29 21:48 白天黑夜每日c 阅读(334) 评论(0) 推荐(0)
摘要:.re:(网上摘) 阅读全文
posted @ 2016-03-26 20:30 白天黑夜每日c 阅读(150) 评论(0) 推荐(0)
摘要:random.sample(sequence, k),从指定序列中随机获取指定长度的片断。sample函数不会修改原有序列 numpy.nonzero() Return the indices of the elements that are non-zero. 阅读全文
posted @ 2016-03-24 19:37 白天黑夜每日c 阅读(270) 评论(0) 推荐(0)