
ptython
jacklinping
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
运行 fabric 报错
File "/usr/lib64/python2.6/site-packages/Crypto/Util/number.py", line 56, in if _fastmath is not None and not _fastmath.HAVE_DECL_MPZ_POWM_SEC: AttributeError: 'module' object has no attribut...原创 2016-05-11 17:38:18 · 357 阅读 · 0 评论 -
Requirement.parse('six
安装influxdb-python 报错 error: Could not find suitable distribution for Requirement.parse('six 。。。。 slution:安装setuptools 解决原创 2017-12-26 09:54:10 · 1585 阅读 · 0 评论 -
python中文乱码问题汇总
将python2中汉字会出现乱码的事一次性说清楚。 为了让初学者,不再为python2中汉字出现乱码的事烦恼! 请看迪艾姆公司python培训上课老师黄哥细细道来: 1、写的代码模块需要指定编码 如果代码没有指定coding,python就默认所有的字符为ASCII码, ASCII码只支持256个字符,ASCII码不支持中文,所以就报错。 所以要在代码前写上#coding:utf-...原创 2016-04-05 14:33:27 · 358 阅读 · 0 评论 -
python模块 安装
1. psutil #pip install psutil 失败, 因为要安装gcc 和 python-devel 后才能安装 psutil #yum -y install gcc python-devel 再 安装psutil #pip install psutil 成功! 2. scipy sudo apt-get install liblapack-dev ...原创 2016-03-28 16:38:34 · 150 阅读 · 0 评论 -
python 读。写文件(read,readline,readlines)
f = open("file") --------------------------- read 读取 整个文件 re = f.read() ---------------------------- readline 读取一行 res = f.readline() ;f.readline()[:] 行首到行尾 eg: 按行遍历整个文件,到文件尾则 结束,空行不会结束。 ...原创 2015-12-28 18:56:20 · 226 阅读 · 0 评论 -
正则表达式 re
import re 1.匹配数字和字母 re.match(r'.*\w.*' , text ); 2。re.split(r'\w', text) 以 数字或字母 切割 text字符串 3。匹配 指定 中文字符串“呵呵” text = "我讨厌呵呵" re.search(u'呵呵',text) 若匹配不到返回None 4,匹配电话号码 (800)500-29156245 ...原创 2015-12-08 16:00:34 · 188 阅读 · 0 评论 -
URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify fai
URLError: 用python2.7.9 向https://××××××× post 数据时 报错。 原因: 网站用了自己的证书而非官方授权的证书 解决方法:#不用验证 证书 import ssl ssl._create_default_https_context = ssl._create_unverified_context ...原创 2016-11-08 16:56:23 · 232 阅读 · 0 评论 -
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-6 solution : import sys reload(sys) sys.setdefaultencoding("utf-8")原创 2015-11-27 11:07:17 · 1301 阅读 · 0 评论 -
No module named cassandra.cluster
No module named cassandra.cluster solution: $ pip install cassandra-driver原创 2015-11-27 10:09:02 · 1028 阅读 · 0 评论 -
scrapy 抓的段子里的 \n 去不掉
''.join(sel.css("div.item-content::text").extract()).strip() 数据库里的 段子 还是有 \n 如下: "body" : "我一朋友他恋上一位女神,头一次表白被谢绝了,他掉头就走。\n几天后女神主动找他问:你咋只表白一次?为什么不多表白几次?\n于是朋友说了一番话:“刮奖刮到一个谢字就足够了。爱情也一样,没有必要把‘谢谢惠顾...2015-11-19 17:55:02 · 720 阅读 · 0 评论 -
urllib2 get post
python post,get 的 方法 post #参数有 data 就是 post,没有data 是 get 1 url="https://api.ext.m-m10010.com/open/unicom/BatchQueryTerminal" data = {"userId":MLB_USERID,"num":imsis,"num_type":"imsi","timestamp.原创 2016-10-13 11:47:13 · 118 阅读 · 0 评论 -
python 字符串处理
python 把字符串 转换成 字典 a={"cardtype":"A711","dt":"1447223787","token":"6C7C75327CC6FB4C77051E2BBD85CFAF","appid":"13a876d53ee4da1a","tid":"17bf1867aa5d4d8e8c0f15a19原创 2015-11-16 16:16:21 · 135 阅读 · 0 评论 -
python mongodb 正则查询
result = db.devices.find({'$and':[{'stats.fwver': v},{'username':{'$regex':r'(?i)ltu'}}]})#匹配ltu result = db.devices.find({'$and':[{'stats.fwver': v},{'username':{'$regex':r'^[\d+]'}}]})#匹配数字...原创 2015-10-09 14:50:09 · 681 阅读 · 0 评论 -
python fabric env.host 不起作用
env.host=['server1'] 结果还是得输入主机名 改为如下: env.host_string = 'server1' # ‘root@cca1.szime.com’ 这样就不用输入host 和password了。前提是ssh已经打通 ---------------------------------------- env.roledefs = { 's1...原创 2015-08-18 10:46:14 · 523 阅读 · 0 评论 -
linux下python指定编码写文件让windows下查看不乱码
import sys import chardet reload(sys) print sys.getdefaultencoding() >> ascii sys.setdefaultencoding('utf-8') #重新指定python 的编码格式 print sys.getdefaultencoding() >> utf-8 python 默认的编码是ascii ...原创 2018-03-26 12:34:57 · 533 阅读 · 0 评论