
Python
得一录
这个作者很懒,什么都没留下…
展开
-
利用python获取linux系统时间
vi testtime.pyimport timeprint time.strftime("%Y-%m-%d %H:%M:%S %Z", time.localtime(time.time()));运行python testtime.py下面是文章转转载 2011-10-09 09:32:39 · 5771 阅读 · 0 评论 -
Python配置Pydev2.8.1
PyDev 2.8.1.zip解压缩.在Eclipse安装目录下新建一个links文件夹。然后再在links文件夹下新建名为eclipse的目录,最后把pedev.zip的压缩包内容解压到eclipse目录中。在links目录下,新建一个名为pydev.link的文件,文件的内容为:path=D:\p\eclipse\links\eclipse ,(其中path=D:\p\ec原创 2013-08-02 09:32:04 · 1014 阅读 · 0 评论 -
Python Excel 列名转换
def colname_to_num(colname): if type(colname) is not str: return colname col = 0 power = 1 print len(colname) for i in xrange(len(colname) - 1, -1, -1):原创 2013-05-08 13:05:57 · 2743 阅读 · 1 评论 -
Python创建目录
import osdef createFolder(folderPath): if not os.path.exists(folderPath): try: os.makedirs(folderPath) except Exception, e: print e原创 2013-05-07 09:57:17 · 822 阅读 · 0 评论 -
Python创建目录
import osimport sysimport datetimeimport timeDAILY_TOOL_PATH = 'Z:\\'DAILY_TEST_PATH ='Z:\\TEST'if __name__ == '__main__': cur_time = time.strftime('%Y%m%d %H:%M:%S', time.local原创 2013-05-03 10:35:40 · 560 阅读 · 0 评论 -
Python正则表达式练习
1.import recr = re.compile("怎么写呢") s = "abcd123d123ad1v123" print cr.findall(s) 我想找出以a开头,以123字符串结尾,但是中间不出现123这个字符串的字符串。 比如上题,结果应为:abcd123和ad1v123。2.import recr = re.compi转载 2013-05-02 14:36:37 · 833 阅读 · 0 评论 -
Python复制文件
import osimport os.pathimport shutilimport time, datetimedef copyFiles(sourceDir, targetDir): if sourceDir.find(".svn") > 0: return for file in os.listdir(sourceDir):转载 2013-05-02 10:22:06 · 830 阅读 · 0 评论 -
Python多线程学习
Python多线程学习 一、Python中的线程使用: Python中使用线程有两种方式:函数或者用类来包装线程对象。1、 函数式:调用thread模块中的start_new_thread()函数来产生新线程。如下例: view plaincopy to clipboardprint?import time import threa转载 2013-04-18 17:05:41 · 593 阅读 · 0 评论 -
python判断是否是中文路径
import osmypath = raw_input("Please inmput directory to create:");if not len(mypath): print 'Error: no path specified => exit!' quit();for c in mypath: if ord(c) > 127: p转载 2013-04-26 10:48:45 · 2062 阅读 · 0 评论 -
python range与xrange
range 函数说明:range([start,] stop[, step]),根据start与stop指定的范围以及step设定的步长,生成一个序列。range示例: >>> range(5) [0, 1, 2, 3, 4] >>> range(1,5) [1, 2, 3, 4] >>> range(0,6,2)[0, 2, 4]xrange 函数说明转载 2013-04-18 08:49:10 · 690 阅读 · 0 评论 -
Python获取本机Ip地址
import socketmyname = socket.getfqdn(socket.gethostname())myaddr = socket.gethostbyname(myname)print myaddr转载 2013-04-17 16:21:16 · 3647 阅读 · 0 评论 -
Python 操作配置文件
import ConfigParsercf = ConfigParser.ConfigParser()cf.read("config.ini")s = cf.sections()#print 'section:', so = cf.options("db")#print 'options:', ov = cf.items("db")#print 'db:',转载 2013-04-17 11:20:49 · 819 阅读 · 0 评论 -
python操作Excel读写--使用xlrd
一、安装xlrd模块 到python官网下载http://pypi.python.org/pypi/xlrd模块安装,前提是已经安装了python 环境。二、使用介绍 1、导入模块 import xlrd 2、打开Excel文件读取数据 data = xlrd.open_workbook('excelFile.xls') 3、转载 2013-04-16 13:07:08 · 809 阅读 · 0 评论 -
Python客户端与服务端网络通讯
server.py: import socketsock = socket.socket(socket.AF_INET,socket.SOCK_STREAM)sock.bind(("", 8080))sock.listen(5)try: while True: newSock,address = sock.accept() pr转载 2013-04-16 11:03:59 · 840 阅读 · 0 评论 -
python显示当前系统时间
import timeprint time.strftime('%Y-%m-%d %H:%M:%S')转载 2013-04-16 14:12:20 · 16579 阅读 · 0 评论 -
python 修改Excel文件
from xlrd import open_workbookfrom xlutils.copy import copyrb = open_workbook('C:\\test_python\\test.xls')rs = rb.sheet_by_index(0)wb = copy(rb)ws = wb.get_sheet(0)ws.write(0,0,'changed!')转载 2013-04-16 13:53:36 · 5355 阅读 · 2 评论 -
Python使用条件变量
互斥锁是最简单的线程同步机制,Python提供的Condition对象提供了对复杂线程同步问题的支持。Condition被称为条件变量,除了提供与Lock类似的acquire和release方法外,还提供了wait和notify方法。线程首先acquire一个条件变量,然后判断一些条件。如果条件不满足则wait;如果条件满足,进行一些处理改变条件后,通过notify方法通知其他线程,其他处于wai转载 2013-04-23 16:36:54 · 995 阅读 · 0 评论 -
Python多线程操作
每个线程互相独立,相互之间没有任何关系。现在假设这样一个例子:有一个全局的计数num,每个线程获取这个全局的计数,根据num进行一些处理,然后将num加1。很容易写出这样的代码:# encoding: UTF-8import threadingimport timeclass MyThread(threading.Thread): def run(self):转载 2013-04-23 15:36:24 · 601 阅读 · 0 评论 -
perl 正则表达式
匹配:m/;/ (还可以简写为 /;/ ,略去 m)替换:s/;/;/转化:tr/;/;/这三种形式一般都和 =~ 或 !~ 搭配使用(其中 "=~" 表示相匹配,在整条语句中读作 does,"!~" 表示不匹配,在整条语句中读作 doesn't),并在左侧有待处理的标量变量。如果没有该变量和 =~ !~ 操作符,则默认为处理 $_ 变量中的内容。举例如下:$str = "I转载 2014-12-23 14:08:37 · 591 阅读 · 0 评论