![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
blackproof
这个作者很懒,什么都没留下…
展开
-
python入门 读写文件
1.打开文件,读取所有内容file_object = open('thefile.txt')try: all_the_text = file_object.read( )finally: file_object.close( ) 2.读取固定字节file_object = open('abinfile', 'rb')try: while True: ...原创 2014-09-13 11:33:50 · 65 阅读 · 0 评论 -
python写mappreduce
(subscribeMonitorCompany()) for line in sys.stdin: try: rs = clean.analyzeData(line) if rs==None or len(rs)<=0: continue print '%s' % (clean.cvtToStr(rs)) except Exception as e: continue2014-11-11 14:02:30 · 118 阅读 · 0 评论 -
python多线程
addRequest(self,request): self.requests.append(request) def run(self): for rq in self.requests: self.giop.grapData(rq.logday,rq.flightDay,rq.depCity,rq.arrCity) self.giop.insertData() print s原创 2014-11-05 20:41:57 · 63 阅读 · 0 评论 -
python 抓取网页
c.setopt(c.WRITEFUNCTION, buf.write) c.perform() content = buf.getvalue() buf.close() jc = json.loads(content) # 设置超时时间为30秒 import socket socket.setdefaulttimeo原创 2014-11-05 20:39:26 · 86 阅读 · 0 评论 -
python 'ascii' codec can't decode
原创 2014-11-05 17:32:10 · 182 阅读 · 0 评论 -
python继承
原创 2014-12-12 14:23:41 · 61 阅读 · 0 评论 -
python反射
hasattr(p,'name') print getattr(p,'name') #反射属性fuc = getattr(p,'hi') #反射方法apply(fuc) #调用方法print callable(getattr(p,'hi'))#方法是否可调用pp = globals()['PP']#获取classppp = pp('dirk.zhang')#实例化对象ppp.hi()print '---' 以下转个帖子http://guoshiguan.i原创 2014-11-03 20:30:51 · 81 阅读 · 0 评论 -
python读写xls
table.ncols; print rownumi=0while i<rownum: rowValue = table.row_values(i); j = 0 while j<colnum: print rowValue[j] j = j+1; print table.row_values(i) i = i+1 for i in range(原创 2014-09-13 20:40:12 · 95 阅读 · 0 评论 -
python入门 读写文件
en('abinfile', 'rb')try: while True: chunk = file_object.read(100) if not chunk: break do_something_with(chunk)finally: file_object.close( ) 3.读取文件一行f = open("D:\\test\\BlueSoftSetup.log","r&quo原创 2014-09-13 11:33:50 · 62 阅读 · 0 评论 -
python继承
import math #class Point class Point: def __init__(self, xValue, yValue): self.X = xValue self.Y = yValue #class Circle class Circle(Point): ...原创 2014-12-12 14:23:41 · 69 阅读 · 0 评论 -
python多线程
python多线程class grapThread(threading.Thread): def __init__(self,conf,mbconf): threading.Thread.__init__(self) self.requests=[] def addRe...原创 2014-11-05 20:41:57 · 72 阅读 · 0 评论 -
python反射
python反射:class PP(): def __init__(self,name): self.name=name def hi(self): print 'hi',self.name p=PP('naughty') #p.hi() #f=hasatt...原创 2014-11-03 20:30:51 · 53 阅读 · 0 评论 -
python读写xls
读取xls: xls_data = xlrd.open_workbook('D:\\delete\\aaaaaa.xls')sheetName = xls_data.sheet_names();print sheetName table = xls_data.sheets()[0] rownum = table.nrows;colnum = table.nc...原创 2014-09-13 20:40:12 · 94 阅读 · 0 评论 -
python深浅复制,类型转换, json操作,数组操作
贝,深拷贝 python类型转换 1 函数 描述 2 int(x [,base ]) 将x转换为一个整数 3 long(x [,base ]) 将x转换为一个长整数 4 float(x ) 将x转换到一个浮点数 5 complex(real [,imag ]) 创建一个复数 6 str(x ) 将对象 x 转换为字符串 7 repr(x原创 2015-07-10 14:07:11 · 944 阅读 · 0 评论