![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
feixue0000
这个作者很懒,什么都没留下…
展开
-
python 正则表达式的使用
import re import time #要进行正则匹配的原字符串 srcstr = r"http://write.bolg.csdn.python_2013_08_04_21.net" #假如要匹配字符串中的日期和时间,然后替换为当天的 datestr = time.strftime("%Y_%m_%d_%H",time.localtime(time.time())) #正则表达原创 2013-08-04 21:41:04 · 475 阅读 · 0 评论 -
python列表遍历浅谈
namelist = ["zhangsan","lisi","wangwu","zhaoliu","zhaoting"] phonelist = ["00000","00001","00002","00004","00005"] #方式一遍历: for name in namelist: print name #方式二遍历: for idx in range(len(namelist)原创 2013-08-04 21:51:01 · 716 阅读 · 0 评论 -
python csv文件写入
#codeing: utf-8 import csv #如果打开模式为“w”,则写入的csv文件,每行后面多一空行 #使用打开模式为”wb“,解决该问题 csvfile = open("1.csv","wb") writer = csv.writer(csvfile) writer.writerow(['name','id','telephone']) writer.writerow原创 2013-08-28 23:01:46 · 2862 阅读 · 0 评论 -
python使用技巧(一)
四:python使用技巧 1. 模式匹配 sTime = "\d{2}:\d{2}:\d{2}.\d{3}.\d{3}" p = re.compile(sTime) match = p.search(str_temp) task_time = 0 if match: task_time = match.group() 2. 目录遍历原创 2013-10-28 18:08:44 · 822 阅读 · 0 评论 -
python pack 和unpack使用
# ref: http://blog.csdn.net/JGood/archive/2009/06/22/4290158.aspx import struct #pack - unpack print print '===== pack - unpack =====' str = struct.pack("ii", 20, 400) pr转载 2014-03-14 16:46:10 · 4615 阅读 · 0 评论 -
python TCP 服务器开发 SocketServer
Python的标准库里的服务器模块SocketServer可以很方便的开发简单的服务器程序 import SocketServer class MyHandler(SocketServer.StreamRequestHandler): def handle(): addr = self.request.getpeername() print 'connect转载 2014-03-14 16:46:58 · 845 阅读 · 0 评论 -
Python特殊语法:filter、map、reduce、lambda
Python特殊语法:filter、map、reduce、lambda [转] Python内置了一些非常有趣但非常有用的函数,充分体现了Python的语言魅力! filter(function, sequence):对sequence中的item依次执行function(item),将执行结果为True的item组成一个List/String/Tuple(取决于sequence的转载 2014-03-14 16:47:41 · 442 阅读 · 0 评论