![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
yue492008824
这个作者很懒,什么都没留下…
展开
-
python内置函数
内置函数常用函数1.数学相关abs(x)abs()返回一个数字的绝对值。如果给出复数,返回值就是该复数的模。>>>print abs(-100) 100 >>>print abs(1+2j) 2.2360679775divmod(x,y)divmod(x,y)函数完成除法运算,返回商和余数。>>> divmod(10,3) (3,转载 2014-03-12 15:19:18 · 393 阅读 · 0 评论 -
用requests爬取百度搜索数据
#-*- coding:utf-8 -*-import requestsimport sysreload(sys)sys.setdefaultencoding('utf-8')headers = {'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:44.0) Gecko/20100101 Firefox/44.0'}pa原创 2016-03-29 23:23:43 · 5864 阅读 · 0 评论 -
文章标题
安装horizon_demo建议在virtualenv环境中运行mkdir demogit clone https://github.com/gabrielhurley/horizon_demo.gitcd horizon_demo/安装依赖包:sudo apt-get install libssl-dev libffi-devpython tools/install_venv.py原创 2015-05-07 10:06:05 · 504 阅读 · 0 评论 -
ubuntu14.04下手动安装openstack juno版
一般照着官方文档做肯定没有问题的,之前一直用redhat的CentOS跟着官方安装都是没有问题的,由于工作需要研究Ceph,CentOS对Ceph的支持不是很好,CentOS7好像都不支持rbd(尽管redhat收购了Ceph,必须要批评一下红帽),桑心啊,没法子了,所以转向了ubuntu。问题:nova list ERROR: HTTPConnectionPool(host='c原创 2015-01-21 10:01:53 · 915 阅读 · 0 评论 -
openstack源码安装过程中的几个坑
openstack源码安装已经做过几遍了,总结了一下常见的jigekeng原创 2014-09-18 14:34:56 · 1418 阅读 · 0 评论 -
python中不能输出中文的解决方法
法一: print u'正数'法二: 加入 import sys reload(sys) sys.setdefaultencoding('utf-8')原创 2014-07-26 13:23:49 · 6067 阅读 · 0 评论 -
抓取网页内容并保存,获取两个字符串之间的内容
抓取网页内容import urllib2url = "http://www.w3cschool.cc/python/python-tutorial.html"urlfile = urllib2.urlopen(url)html = urlfile.read()获取 >>> 和 # 之间的内容:import redef getlist(filename): myfile=open(fi原创 2014-03-14 18:10:27 · 597 阅读 · 1 评论 -
Python中re(正则表达式)模块学习
re.match re.match 尝试从字符串的开始匹配一个模式,如:下面的例子匹配第一个单词。import retext = "JGood is a handsome boy, he is cool, clever, and so on..."m = re.match(r"(\w+)\s", text)if m:print m.group(0), '\n'转载 2014-03-14 10:58:40 · 396 阅读 · 0 评论 -
日期和时间
Python 日期和时间Python程序能用很多方式处理日期和时间。转换日期格式是一个常见的例行琐事。Python有一个time and calendar模组可以帮忙。什么是Tick?时间间隔是以秒为单位的浮点小数。每个时间戳都以自从1970年1月1日午夜(历元)经过了多长时间来表示。Python附带的受欢迎的time模块下有很多函数可以转换常见日期格式。如函数原创 2014-03-13 16:19:09 · 969 阅读 · 0 评论 -
用Python来写5种排序方法
中C语言的毒太深了,目前在自学Python,一时兴起用Python写了五种排序1.冒泡排序:def bubble_sort(l): for i in range(len(l)-1,0,-1): for j in range(0,i): if l[j] > l[j+1]: l[j],l[j+1]=l[j+原创 2014-03-13 13:55:16 · 918 阅读 · 0 评论 -
django修改models重建数据库
第二次修改models.py以后再次 python manage.py makemigrations提示如下You are trying to add a non-nullable field 'address' to xc_users without a default; we can't do that (the database needs something to populat原创 2016-04-27 18:28:51 · 3463 阅读 · 0 评论