随笔分类 -  python

摘要:功能:远端执行python函数远端执行命令传输文件远端交互--------------------------------------------------------------------------------安装方式:pip install Fabric --------------------------------------------------------------------------------入门:第一步:编写命令在python文件fabfile.py 中,这样的好处对交互过程可控 from __future__ import with_statementfro. 阅读全文
posted @ 2013-05-29 16:55 lxgeek 阅读(289) 评论(0) 推荐(0)
摘要:安装 easy_install1.在https://pypi.python.org/pypi/setuptools上下载 setuptools-0.6c11-py2.7.egg 2.执行sh setuptools-0.6c11-py2.7.egg 安装pipwget http://python-distribute.org/distribute_setup.pypython distribute_setup.pywget https://github.com/pypa/pip/raw/master/contrib/get-pip.pypython get-pip.py 阅读全文
posted @ 2013-05-23 18:10 lxgeek 阅读(758) 评论(0) 推荐(0)
摘要:第一步:编译安装 wsgi1.wget https://modwsgi.googlecode.com/files/mod_wsgi-3.4.tar.gz2.tar zxvf mod_wsgi-3.4.tar.gz 3. ./configure --with-apxs=/usr/sbin/apxs4.make 5.make install6.make clean7.make distclean第二步:设置路基wsgi 设置import sys#sys.path.append('/var/www/html/gdnsplus_conf/')path = '/usr/local 阅读全文
posted @ 2013-05-10 17:03 lxgeek 阅读(1012) 评论(0) 推荐(0)
摘要:1.初始环境安装httpd相关的RPM包版本号:httpd-2.2.3-63.el5.centos.1httpd-devel-2.2.3-63.el5.centos.1apr-1.2.7-11.el5_3.1apr-devel-1.2.7-11.el5_3.1apr-util-1.2.7-11.el5apr-util-devel-1.2.7-11.el52.编译python 2.7./configure -enable-sharedwget http://www.python.org/ftp/python/2.7/Python-2.7.tar.bz2tar jfvx Python-2.7.t. 阅读全文
posted @ 2013-05-03 18:02 lxgeek 阅读(1445) 评论(0) 推荐(0)
摘要:用法: python test.py /home/lx/c/test#test how much lines in a directory.import os,sysdef cout( current_doc ): os.chdir( current_doc ) doc_list = os.listdir( current_doc ) for i in doc_list: if os.path.isfile( i ): os.system( 'wc -l ' +... 阅读全文
posted @ 2012-03-30 16:09 lxgeek 阅读(183) 评论(0) 推荐(0)
摘要:#author=lx#date=2011-12-27import osimport sysclass node: "store the information of a node in bnt" def __init__( self, nodename=None, cptnum=2, pnum=0, cnum=0, parename=None, childname=None ): self.node_name = nodename self.cpt_num = cptnum s... 阅读全文
posted @ 2011-12-27 19:47 lxgeek 阅读(623) 评论(0) 推荐(0)
摘要:# A dictionary of movie critics and their ratings of a small# set of moviesfrom math import sqrtcritics = { 'Lisa Rose': { 'Lady in the Water': 2.5, 'Snakes on a Plane': 3.5,'Just My Luck':3.0, 'Superman Returens':3.5, 'You, Me and Dupree': 2.5,'Th 阅读全文
posted @ 2011-11-07 18:27 lxgeek 阅读(691) 评论(0) 推荐(0)
摘要:getattr函数,可以得到一个直到运行时才知道名称的函数的应用。>>> li = [ "Larry", "Curly" ]>>> li.pop<built-in method pop of list object at 0xb76b364c>>>> getattr( li, "pop" )<built-in method pop of list object at 0xb76b364c>>>> getattr( li, "app 阅读全文
posted @ 2011-10-29 12:42 lxgeek 阅读(1466) 评论(0) 推荐(0)
摘要:#__author__=lx#__date__=2011-10-03#__brief__=DFStime = 0d = []f = []color = []p = []def DFS_VISIT( G, i ): color[ i ] = 'gray' global time time += 1 d[i] = time print i+1 for v in G[i]: if color[v-1] == 'white': p[v-1] =... 阅读全文
posted @ 2011-10-03 20:21 lxgeek 阅读(240) 评论(0) 推荐(0)
摘要:#__author__=lx#__date__=2011-10-03#__brief__=BFSfrom collections import dequedef BFS( G, s ): d = [] color = [] p = [] L = deque() for i in range( len( G ) ): if i != s: color.append( 'white' ) d.append( ... 阅读全文
posted @ 2011-10-03 19:52 lxgeek 阅读(357) 评论(0) 推荐(0)
摘要:#__author__=lx#__date__=2011-09-29#__brief__=Heap_sortdef left( i ): return 2*idef right( i ): return 2*i + 1def swap( a1, a2 ): return a2, a1def max_heap( A, i ): if i == 0: return l = left( i ) r = right( i ) largest = i if l <... 阅读全文
posted @ 2011-09-29 18:51 lxgeek 阅读(134) 评论(0) 推荐(0)
摘要:#__author__=lx#__date__=2011-09-27#__brief_=shell_sortdef shell_sort( l ): gap = 0 n = len( l ) while ( gap <= n ): gap = gap * 3 + 1 while ( gap > 0 ): i = gap while ( i < n ): j = i - gap ... 阅读全文
posted @ 2011-09-27 09:29 lxgeek 阅读(141) 评论(0) 推荐(0)
摘要:#__author__=lx#__date__=2011-09-26#__brief__=bubble_sortdef swap( a1, a2 ): return a2, a1def bullble_sort( l ): b = l for i in l: n = b.index( i ) j = 0 q = True while ( j < len( l ) - n - 1 ): if... 阅读全文
posted @ 2011-09-26 15:24 lxgeek 阅读(176) 评论(0) 推荐(0)
摘要:fromhttps://gist.github.com/1130407#!/usr/bin/python# -*- coding: utf-8 -*-"""A simple thread pool.@author: Junaid P V@license: GPLv3""" from threading import Thread, RLock, Lockfrom time import sleepfrom functools import wrapsdef synchronous( tlockname ): ""& 阅读全文
posted @ 2011-08-09 21:04 lxgeek 阅读(1294) 评论(0) 推荐(0)

点击右上角即可分享
微信分享提示