摘要: from multiprocessing import Processdef f(name): print ('hello',name)if __name__ == '__main__': p=Process(target=f,args=('freeman',)) p.start() p.join( 阅读全文
posted @ 2016-05-10 16:30 FreeMan1 阅读(265) 评论(0) 推荐(0) 编辑
摘要: 多线程 import threadingimport timedef say(name): print ('hello world,iam %s'%(name)) time.sleep(30) print ('say finished%s'%(name))res_list = []for i in 阅读全文
posted @ 2016-04-28 14:19 FreeMan1 阅读(184) 评论(0) 推荐(0) 编辑
摘要: FtpServer #!/usr/bin/env python import SocketServer class MyServer(SocketServer.BaseRequestHandler): def setup(self): pass def handle(self): path='/tm 阅读全文
posted @ 2016-04-23 23:20 FreeMan1 阅读(1682) 评论(0) 推荐(0) 编辑
摘要: [root@localhost day5]# cat server.py import socket HOST=''PORT=50007s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)s.bind((HOST,PORT))s.listen(1)wh 阅读全文
posted @ 2016-04-20 19:43 FreeMan1 阅读(153) 评论(0) 推荐(0) 编辑
摘要: import MySQLdbconn = MySQLdb.connect(host='127.0.0.1',user='root',passwd='redhat',db='test',port=3306)cur = conn.cursor()#cur.execute('select * from t 阅读全文
posted @ 2016-04-19 19:34 FreeMan1 阅读(220) 评论(0) 推荐(0) 编辑
摘要: def search(data_set,find_num): mid = len(data_set) /2 print mid if len(data_set) == 1: if data_set[mid] == find_num: print ('End start: ',find_num) re 阅读全文
posted @ 2016-04-19 18:11 FreeMan1 阅读(173) 评论(0) 推荐(0) 编辑
摘要: class Singleton(object): def __new__(cls,*args,**kwargs): if not hasattr(cls,'_inst'): cls._inst=super(Singleton,cls).__new__(cls,*args,**kwargs) retu 阅读全文
posted @ 2016-04-19 18:11 FreeMan1 阅读(438) 评论(0) 推荐(0) 编辑
摘要: 1.json 和 PKL JSON和PkL 有两种Python支持的一种数据有个比较通用的方法 load和dump方法 2.迭代器 迭代器是什么?迭代器是读一行记录一行,只记录开始和下一行直接结束 3.深浅Copy 深浅COPY就是数据指向内存的地址是否会产生一个新内存地址 比如a={} b=a 这 阅读全文
posted @ 2016-04-15 14:47 FreeMan1 阅读(239) 评论(0) 推荐(0) 编辑
摘要: a=[21,9,3,5,12,10,1,13,15]for i in range(len(a)-1,-1,-1): #print (i) for j in range(i): #print (j) if a[j] > a[j+1]: a[j],a[j+1]= a[j+1],a[j] #print ( 阅读全文
posted @ 2016-04-13 16:44 FreeMan1 阅读(304) 评论(0) 推荐(0) 编辑
摘要: 类,对象,实例化class Person(object): def __init__(self,name,age): self.name=name self.age= age def run(self): print ("Runing %s"%(self.name)) def speak(self, 阅读全文
posted @ 2016-04-12 19:11 FreeMan1 阅读(250) 评论(0) 推荐(0) 编辑