2013年3月27日

python 冒泡排序

摘要: 1#!/usr/bin/envpython2#coding:utf-834#**********************************5#author:h3idan6#datetime:2013-03-1318:427#**********************************8910defbubble_sort(list1):11foriinranage(len(a)-1):12forjinrange(len(len(a)-i-1)):13iflist1[j]>list1[j+1]:14list1[j],list1[j+1]=list1[j+1],list1[j]1 阅读全文

posted @ 2013-03-27 15:10 h3idan 阅读(123) 评论(0) 推荐(0) 编辑

2012年10月3日

把nginx加入系统服务!!

摘要: 下载源码包回来http://nginx.org/download/nginx-1.2.4.tar.gz编译安装。编译之前查看是否安装pcre-devel,openssl,openssl-devel。装好之后进入nginx的目录下。默认是/usr/local/nginx编辑一个shell脚本文件。vim /etc/init.d/nginx 1 #!/bin/bash 2 # nginx Startup script for the Nginx HTTP Server 3 # it is v.0.0.2 version. 4 # chkconfig: - 85 15 5 # description 阅读全文

posted @ 2012-10-03 12:37 h3idan 阅读(332) 评论(0) 推荐(0) 编辑

2012年9月27日

django+uwsgi+nginx环境搭建、部署!

摘要: 选择版本:uwsgi :http://projects.unbit.it/downloads/Flup:http://www.saddi.com/software/flup/dist/flup不是可以直接拿来用的东西。flup是使用 Python 语言对 WSGI 的一种实现,是可以用于 Python 的应用开发中的一种工具或者说是一种库。Nginx:http://www.nginx.org/download/因为要用xml配置django.xml,安装libxml2-dev*1 yum install -y libxml2-dev*安装uwsgi:1 tar zxvf uwsgi-lates 阅读全文

posted @ 2012-09-27 00:54 h3idan 阅读(1015) 评论(0) 推荐(0) 编辑

2012年9月5日

git pull 后报错问题

摘要: 下面的错误: 1 $ git pull 2 Password: 3 You asked me to pull without telling me which branch you 4 want to merge with, and 'branch.master.merge' in 5 your configuration file does not tell me, either. Please 6 specify which branch you want to use on the command line and 7 try again (e.g. 'git p 阅读全文

posted @ 2012-09-05 13:24 h3idan 阅读(329) 评论(0) 推荐(0) 编辑

2012年8月27日

centos 使用 root运行chrome

摘要: 第一种方法:[root@h3idan /]# vim /opt/google/chrome/google-chrome编辑最后一行代码:exec -a "$0" "$HERE/chrome" "$@" --user-data-dir然后保存。第二种方法:[root@h3idan /]# vim /opt/google/chrome/chrome查找到 geteuid 改为 getppid。然后保存!具体是怎么回事不知道,但是能用就行了! 阅读全文

posted @ 2012-08-27 18:12 h3idan 阅读(684) 评论(0) 推荐(0) 编辑

2012年7月29日

django1.4 在SAE上部署!

摘要: 直奔主题:建好应用之后把config.yaml文件修改好,如下: 1 name: 你的应用名称 2 version: 1 3 4 libraries: 5 - name: django 6 version: "1.4" 7 8 handlers: 9 - url: /static10 static_dir: static修改好之后把文件文件目录修改掉:django1.4的文件目录结构:改成:这个是改完之后。就是把django1.4的目录结构改成1.3目录结构就可以了。剩下的就和其他的是一样的!! 阅读全文

posted @ 2012-07-29 23:41 h3idan 阅读(318) 评论(0) 推荐(0) 编辑

2012年7月26日

beautifulsoup的使用

摘要: 靓汤很好用,代码直接减少一半 1 urls = [] 2 queue = Queue.Queue() 3 4 def geturl(url): 5 6 html = urllib2.urlopen(url).read() 7 soup = BeautifulSoup(html) 8 tag_a = soup.findAll('a', href=True) 9 for i in tag_a:10 s = i['href']11 if s.startswith('#'):12 pass13 ... 阅读全文

posted @ 2012-07-26 16:33 h3idan 阅读(324) 评论(0) 推荐(0) 编辑

2012年7月25日

写了一个单线程的爬虫。多线程的还在研究!

摘要: 废话不多说,直接上代码。请多多指点!! 1 #!/usr/bin/env python 2 #-*- coding = utf-8 -*- 3 # author: h3i_dan 4 # version: v1.0 5 ######################### 6 7 import urllib 8 from sgmllib import SGMLParser 9 10 class Urllist(SGMLParser):11 12 def reset(self):13 SGMLParser.reset(self)14 self.urls =... 阅读全文

posted @ 2012-07-25 10:27 h3idan 阅读(199) 评论(0) 推荐(0) 编辑

2012年5月29日

比较两个文件

摘要: 写的比较简单。主要是想要比较每个目录中的文件是否一样。就直接通过dir 遍历出了所有的文件。把他们放入txt中,如果有不一样,我就直接查看,没有的话,就不看了。剩了不少事情。看代码吧,刚学python,写得不好,大家见笑了! 1 #!/usr/bin/env python 2 # coding: utf-8 3 # author: h3i_dan 4 # filename: compare_dir.py 5 # version: v1.0 6 ############################ 7 8 9 import os10 import sys11 12 13 def rea... 阅读全文

posted @ 2012-05-29 17:37 h3idan 阅读(168) 评论(0) 推荐(0) 编辑

2012年5月26日

py2exe 使用的心得

摘要: 想要在服务器上运行python的程序,还要搭环境,虽然搭环境不是很麻烦,但是比起来直接能运行还是比较麻烦的。百度了一下,基本上按照他们的方法就ok了。先去下载一个py2exe回来,直接安装。貌似现在只支持到python 2.6.6 ,其他版本不知道。最开始我装2.7.3的。安装的时候发现安装不了,一看才知道只能2.6版本的。不够仔细呀!先说下步骤吧。1)直接安装python的目录下就行了,直接下一步,py2exe直接找到python2.6的目录2)装完之后。在python的目录下新建一个setup.py的文件。代码如下:1 from distutils.core import setup2 i 阅读全文

posted @ 2012-05-26 23:25 h3idan 阅读(937) 评论(0) 推荐(0) 编辑

导航