python
文章平均质量分 50
daidaixiong1234
如果我写的对你有用,记得踩一下哦~~~
展开
-
Python里的string 和 unicode
转载http://blog.csdn.net/ktb2007/article/details/3876429首先要弄清楚的是,在Python里,string object和unicode object是两种不同的类型。string object是由characters组成的sequence,而unicode object是Unicode code units组成的s转载 2016-07-18 16:24:53 · 498 阅读 · 0 评论 -
python中关键词with的使用
http://stackoverflow.com/questions/3012488/what-is-the-python-with-statement-designed-for非常好的回答,值得花时间粘过来,粗浅理解就是with利用context managers来为我们要执行的一些操作做预处理和最后的收尾,也就是把try和finally的操作放在了里面,我们再用with调用的时候,就简化了转载 2016-05-10 11:08:09 · 726 阅读 · 0 评论 -
python os.path与路径相关的
记性不好,赶紧记一下吧os.listdir(dirname) 列出dirname下所有文件os.path.abspath(dirname) 给出dirname的绝对路径os.path.dirname(dirname) 给出dirname的上一级目录os.path.exist(path) 判断path是否存在原创 2016-04-09 15:18:31 · 623 阅读 · 0 评论 -
scrapy设置代理proxy
http://stackoverflow.com/questions/4710483/scrapy-and-proxies增加文件middlewares.py放置在setting.py平行的目录下import base64class ProxyMiddleware(object):# overwrite process requestdef process_request原创 2016-03-24 16:50:11 · 15273 阅读 · 2 评论 -
登陆多台远程服务器,执行程序
1. parallel-ssh 亲测有效2. paramiko 用过, 当时是要运行时间很长的任务, 任务里面调用了插件, 发现运行一段时间之后, 程序就无缘无故被挂起了, 还未找到愿意3. fabfile 官网http://www.fabfile.org/, 上面有个例子, 看着听方便了, 但是说是调用了paramiko, 担心出现2中说的问题, 还未测, 下次再有需要时, 可测试一下原创 2015-12-15 19:22:20 · 5939 阅读 · 0 评论 -
python string转为dict --- json.loads
import jsoncontent = "{\"Location\":{\"Store\":{\"StoreRegionID\":300,\"StoreGroupID\":394,\"StoreDistrictID\":340},\"TypeDescription\":\"Store\",\"AlternateIdentifier\":{\"TypeDescription\":\"L原创 2015-10-14 19:20:05 · 7561 阅读 · 0 评论 -
ubuntu安装mysqldb
sudo apt-get install python2.7-mysqld原创 2015-09-25 13:58:16 · 5910 阅读 · 0 评论 -
python模块imghdr读图片后缀名
爬数据的时候常常遇到img标签的src中不包含图片的后缀名,如http://photos.prnewswire.com/prn/20100819/LA52539LOGO所示,这时通过imghdr模块就能够把图片的后缀名读出来例子:import urllib2import imghdrurl = 'http://photos.prnewswire.com/prn/20100原创 2015-09-24 17:17:16 · 7962 阅读 · 0 评论 -
ubuntu 14.04 安装gensim
1. 安装依赖库:Python >= 2.6. Tested with versions 2.6, 2.7, 3.3 and 3.4. Support for Python 2.5 was discontinued starting gensim 0.10.0; if you must use Python 2.5, install gensim 0.9.1.NumPy >= 1.原创 2015-10-21 19:46:36 · 9798 阅读 · 0 评论 -
what yield does in python?
http://stackoverflow.com/questions/231767/what-does-the-yield-keyword-do-in-pythonyield->generator(生成器)->iterable(迭代器)Everything you can use "for... in..." on is an iterable: lists, strings,原创 2015-10-21 13:33:23 · 6126 阅读 · 0 评论 -
kdtree c++版本
等我实现一个python版本的再贴上来http://blog.csdn.net/zhl30041839/article/details/9277807一、如何高效率地实现k近邻法? 在SIFT图像特征匹配等应用中,需要在高维特征空间中快速找到距离目标图像特征最近邻的那个特征点,往往需要进行比较的特征向量的数量很大,如果进行朴素最近邻搜索,也就是依次计算目标转载 2016-07-19 20:48:04 · 5295 阅读 · 2 评论