哪有这么简单

那python 是能实现我这样的 意思吗?
写法不懂可以慢慢研究,先得知道结果。
如果这个是不可能实现的 ,那我 还研究啥呢
你这种是没法实现的
必须带导模块 还有种方法
我的想实现的 是 多线程共同写 一个 列表,加快速度
同时进行
import threading
from queue import Queue
data = []
class DataFun(threading.Thread):
def __init__(self,i,i_queue):
super().__init__()
self.i = i
self.i_queue = i_queue
def run(self):
while True:
if self.i_queue.empty():
# print( 完成 )
break
i =self.i_queue.get()
self.fun(i)
def fun(self,i):
global data
data.append([1,2,3])
if __name__ == __main__ :
i_queue =Queue()
for i in range(4):
i_queue.put(i)
threads = []
for j in range(4):
crawl = DataFun(j,i_queue)
crawl.start()
threads.append(crawl)
for thread in threads:
thread.join()
print(data)
线程可以直接通信 进程不行
给他说队列 他不听
队列和栈 ,不挺基础
我都知道
好像不能在空列表里面给指定的索引赋值吧
会报错
谢谢大佬
我研究下先