摘要:
单线程执行代码: 1 import time 2 3 4 def saySorry(): 5 print("测试代码") 6 time.sleep(1) 7 8 9 if __name__ == '__main__': 10 for i in range(5): 11 saySorry() 单线程下 阅读全文
摘要:
1 from multiprocessing import Pool 2 import os, time, random 3 4 5 def worker(msg): 6 t_start = time.time() # 获取开始时间 7 print("%s开始执行,进程号为%d" % (msg, o 阅读全文
摘要:
简介:同一时间,聊天器两端均可收发数据 1 import socket 2 import threading 3 4 udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 5 6 7 def send_msg(dest_ip, d 阅读全文
摘要:
效果: 客户端 服务器 客户端代码: 1 import socket 2 3 4 def main(): 5 while True: 6 # 1.创建套接字 7 client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 8 9 阅读全文