一.threading.loacl方法 import threading import time class Foo: pass foo = Foo() def func(num): foo.num = num time.sleep(1) # 都睡一秒 还没来得及输出,就被后来的线程改了,所以等睡完之后,所有线程打印的num就都变为都后一次改得了 print(foo.num, threading.current_thread().ident) for i in range(20): th = t…
一,threading.local() import time import threading v = threading.local() def func(arg): # 内部会为当前线程创建一个空间用于存储:phone=自己的值 v.phone = arg time.sleep(2) print(v.phone,arg) # 去当前线程自己空间取值 for i in range(10): t =threading.Thread(target=func,args=(i,)) t.start(…
前提:基于纯后端服务, post 请求 (Content-Type: application/json,) 1.获取未经处理过的原始数据而不管内容类型,如果数据格式是json的,则取得的是json字符串,排序和请求参数一致 c = request.get_data() 2.将请求参数做了处理,得到的是字典格式的,因此排序会打乱依据字典排序规则 c =request.get_json() 3.可以获取未经处理过的原始数据,如果数据格式是json的,则取得的是json字符串,排序和请求参数一…
查看 app.route() 源代码 def route(self, rule: str, **options: t.Any) -> t.Callable: """Decorate a view function to register it with the given URL rule and options. Calls :meth:`add_url_rule`, which has more details about the implementation. .…