Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/337.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python中,如何为threadpoolexecutor传递两个参数?_Python - Fatal编程技术网

在python中,如何为threadpoolexecutor传递两个参数?

在python中,如何为threadpoolexecutor传递两个参数?,python,Python,上面是我的示例代码格式。我想在_names()的列表_中使用ThreadPoolExecutor传递名称和键值以检查_和_execute() 我应该列一张钥匙和名字的清单并用地图来做吗?或者我可以使用partial和map组合将各自的值传递给其他函数吗 from concurrent.futures import ThreadPoolExecutor from functools import partial threads = ThreadPoolExecutor(max_workers=2

上面是我的示例代码格式。我想在_names()的列表_中使用ThreadPoolExecutor传递名称和键值以检查_和_execute()

我应该列一张钥匙和名字的清单并用地图来做吗?或者我可以使用partial和map组合将各自的值传递给其他函数吗

from concurrent.futures import ThreadPoolExecutor
from functools import partial

threads = ThreadPoolExecutor(max_workers=20)

def check_and_execute(name, key):
        response = s.get(f"www.google.com?search={name}", verify=False)
        data = response.get_json()["content"]
        if data["host_name"] == key:
                return data["host_name"]

def list_of_names(hub="abcdef"):
       response = s.get(f"www.abcd.com?search={hub}", verify=False)
       data = response.get_json()["content"]
       for x in range(len(data)):
              key = data["host_key"]
              name = data["name_of_host"]