摘要:
目的 1.判断用户输入的数据是否满足要求 2.快速查找满足条件的数据 使用方法: import re ret=re.match(r"","") ret.group()#获取匹配的数据 匹配单个字符: \d 数字0-9 ,可以使用[]来限定特定的数字或字母,如:[123678],若为连续可使用-来表示 阅读全文
摘要:
class Classmate(): def __init__(self): self.name = list() self.current = 0 #print(self.name) def add(self,name): self.name.append(name) #print(self.na 阅读全文
摘要:
import osimport multiprocessingdef copy_file(q,file_name,old_folder_name,new_folder_name): """完成文件的复制""" old_f=open(old_folder_name+"/"+file_name,"rb" 阅读全文
摘要:
import multiprocessing q1=multiprocessing.Queue(50)#括号中的数据可有可无,若无时,无大小限制 q1.put(111) q1.put(222) q1.get() q1.put_nowait("111")#若满了,将抛出异常 q1.get_nowait 阅读全文
摘要:
import multiprocessing imprort time def test(): while True: print("_______________11_______") time.sleep(1) def main(): p1=multiprocessing.Process(tar 阅读全文
摘要:
资源竞争解决方法 1:加锁,解锁 mutex =threading.Lock() mutex.acquire()#加锁 mutex.release()#解锁 2:容易死锁 需要添加等待时间或者使用算法解决 阅读全文
摘要:
import threading def test(): #def test(temp): for i in range(4): print(i) def test1(): for i in range(4): print(i) a=10 def main(): t1=threading.Threa 阅读全文
摘要:
names=["aa","bb","cc"] for i in names: print(i) =>>aa =>>bb =>>cc for i in enmuerate(names): print(1) =>>(0,'aa') =>>(1,'bb') =>>(2,'cc') #增加拆包时 for i 阅读全文
摘要:
1.tcp服务器一般情况下都需要绑定,否则客户端找不到这个服务器2.tcp客户端一般不绑定,因为是主动链接服务器,所以只要确定好服务器的ip、port等信息就好,本地客户端可以随机3.tcp服务器中通过listen可以将socket创建出来的主动套接字变为被动的,这是做tcp服务器时必须要做的4.当 阅读全文
摘要:
import socketdef main(): #1.创建套接字 tcp_socket=socket.socket(socket.AF_INET,socket.SOCK_STREAM) #2.获取服务器的ip,duankou desk_ip=input("请输入服务器ip:") desk_port 阅读全文