from multiprocessing import Process # 有个 url 列表 ,有5个 url ,一次请求是1秒,5个5秒 # 要求1秒把 url 请求完, a = [] # 在进程中数据不共享, # 解决: 将其变成共享 n = 1 def fun(): global n n = 2 # 做用或只在子进程 if __name__ == '__main__': p = Process(target=fun) p.start() p.join() print(n) # 打印出的是…
index.html 首页 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <!--引入本地--> <link rel…
index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet&quo…
index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet&quo…
index.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet&quo…
类的定义 共同属性,特征,方法者,可分为一类,并以名命之 class Abc: # class 定义类, 后面接类名 ( 规则 首字母大写 ) cls_name = '这个类的名字是Abc' # 在类里定义的变量 是 属性 print( Abc.cls_name ) Abc.binbin = '正在25班教室' # 可以通过 类名.属性名 = 属性值 给类添加属性 print( Abc.binbin ) ------>>>>> 这个类的名字是Abc 正在25班教室 类是一个独…
C/S系统实现两数求和 任务要求: 实现配置文件 实现日志滚动 设置非阻塞套接字,EPOLL实现 检测客户端的连接,设置心跳检测 主线程 + 心跳检测线程 + EPOLL的ET模式处理事务线程 注意事项:设置volatile类型跳出死循环 作品简介: 本次实验分为bin,config,include,log,src五个文件夹以及一个makefile文件,下面是里面的具体内容以及功能详解: bin: 存放二进制文件,生成的可执行文件,执行本系统只需在超级终端打开即可. config: 存放配置文件…
# -*- coding: utf-8 -*- # 斌彬电脑 # @Time : 2018/7/12 0012 20:29 import socket server = socket.socket() server.setblocking(False) server.bind(('',10000)) # 绑定ip,和端口, server.listen(5) con_l = [] while 1: try: con,addr = server.accept() con.setblocking(Fa…
#斐波那契 def fid(n): res = [] indx = 0 a = 0 b = 1 while indx < n : res.append(b) a,b = b,a+b indx += 1 return res print(fid(1000)) # 生成器 def fid(n): indx = 0 a = 0 b = 1 while indx < n : yield b # 暂停并返回 跳出函数 res.append(b) a,b = b,a+b indx += 1 f = fid…
线程,进程,是实现并发的方法, 并行: 在同一时刻,同时运行多个任务,CPU 的数量大于等于任务数量, 并发: 在同一时间间隔内, 同时处理多个任务, 并行是并发. 进程:表示一个正在执行的程序, 操作系统负责其上所有的执行 多进程 import multiprocessing # from multiprocessing import process import time # 模拟一个好使任务 print('a:',time.asctime(time.localtime(time.time(…