{"id":1170690,"date":"2025-01-15T16:25:37","date_gmt":"2025-01-15T08:25:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1170690.html"},"modified":"2025-01-15T16:25:40","modified_gmt":"2025-01-15T08:25:40","slug":"python%e5%a6%82%e4%bd%95%e6%8e%a7%e5%88%b6%e5%a4%9a%e7%ba%bf%e7%a8%8b%e6%95%b0%e9%87%8f","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1170690.html","title":{"rendered":"python\u5982\u4f55\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26073239\/c02d7ae8-f6ee-41c1-9dd8-a0ed2d062512.webp\" alt=\"python\u5982\u4f55\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\" \/><\/p>\n<p><p> <strong>Python\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528ThreadPoolExecutor\u3001Semaphore\u3001Queue\u3001\u901a\u8fc7\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u6c60\u7b49\u3002\u5176\u4e2d\uff0cThreadPoolExecutor\u662f\u6700\u5e38\u7528\u4e14\u65b9\u4fbf\u7684\u4e00\u79cd\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<p><h3>ThreadPoolExecutor<\/h3>\n<\/p>\n<p><p><strong>ThreadPoolExecutor\u662fPython\u4e2d\u7684concurrent.futures\u6a21\u5757\u63d0\u4f9b\u7684\u4e00\u79cd\u9ad8\u7ea7\u63a5\u53e3\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u7ba1\u7406\u7ebf\u7a0b\u6c60\uff0c\u5e76\u63a7\u5236\u5e76\u53d1\u7ebf\u7a0b\u7684\u6570\u91cf\u3002<\/strong>\u4e0b\u9762\u662f\u4e00\u4e2a\u8be6\u7ec6\u7684\u4f8b\u5b50\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528ThreadPoolExecutor\u6765\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from concurrent.futures import ThreadPoolExecutor<\/p>\n<p>import time<\/p>\n<p>def task(name):<\/p>\n<p>    print(f&#39;Task {name} is running&#39;)<\/p>\n<p>    time.sleep(2)<\/p>\n<p>    print(f&#39;Task {name} is completed&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5305\u542b3\u4e2a\u7ebf\u7a0b\u7684\u7ebf\u7a0b\u6c60<\/strong><\/h2>\n<p>with ThreadPoolExecutor(max_workers=3) as executor:<\/p>\n<p>    futures = [executor.submit(task, i) for i in range(10)]<\/p>\n<h2><strong>\u7b49\u5f85\u6240\u6709\u4efb\u52a1\u5b8c\u6210<\/strong><\/h2>\n<p>for future in futures:<\/p>\n<p>    future.result()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2a\u5305\u542b3\u4e2a\u7ebf\u7a0b\u7684\u7ebf\u7a0b\u6c60\uff0c\u7136\u540e\u63d0\u4ea4\u4e8610\u4e2a\u4efb\u52a1\u7ed9\u7ebf\u7a0b\u6c60\u5904\u7406\u3002\u901a\u8fc7<code>max_workers<\/code>\u53c2\u6570\uff0c\u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u5e76\u53d1\u7ebf\u7a0b\u7684\u6570\u91cf\u3002\u7ebf\u7a0b\u6c60\u4f1a\u81ea\u52a8\u7ba1\u7406\u7ebf\u7a0b\u7684\u521b\u5efa\u548c\u9500\u6bc1\uff0c\u5e76\u786e\u4fdd\u540c\u65f6\u8fd0\u884c\u7684\u7ebf\u7a0b\u6570\u91cf\u4e0d\u4f1a\u8d85\u8fc7\u6307\u5b9a\u7684\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><h3>Semaphore<\/h3>\n<\/p>\n<p><p><strong>Semaphore\u662fPython threading\u6a21\u5757\u4e2d\u7684\u4e00\u4e2a\u7c7b\uff0c\u7528\u4e8e\u63a7\u5236\u8bbf\u95ee\u5171\u4eab\u8d44\u6e90\u7684\u7ebf\u7a0b\u6570\u91cf\u3002<\/strong>\u5b83\u53ef\u4ee5\u88ab\u7528\u6765\u9650\u5236\u5e76\u53d1\u7ebf\u7a0b\u7684\u6570\u91cf\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528Semaphore\u6765\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>import time<\/p>\n<p>def task(name, sem):<\/p>\n<p>    with sem:<\/p>\n<p>        print(f&#39;Task {name} is running&#39;)<\/p>\n<p>        time.sleep(2)<\/p>\n<p>        print(f&#39;Task {name} is completed&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aSemaphore\u5bf9\u8c61\uff0c\u5141\u8bb8\u540c\u65f6\u8fd0\u884c3\u4e2a\u7ebf\u7a0b<\/strong><\/h2>\n<p>sem = threading.Semaphore(3)<\/p>\n<p>threads = []<\/p>\n<p>for i in range(10):<\/p>\n<p>    t = threading.Thread(target=task, args=(i, sem))<\/p>\n<p>    threads.append(t)<\/p>\n<p>    t.start()<\/p>\n<p>for t in threads:<\/p>\n<p>    t.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2aSemaphore\u5bf9\u8c61\uff0c\u521d\u59cb\u503c\u4e3a3\uff0c\u8fd9\u610f\u5473\u7740\u6700\u591a\u5141\u8bb83\u4e2a\u7ebf\u7a0b\u540c\u65f6\u8fd0\u884c\u3002\u6bcf\u4e2a\u7ebf\u7a0b\u5728\u8fd0\u884c\u65f6\u4f1a\u5148\u83b7\u53d6Semaphore\u5bf9\u8c61\uff0c\u5982\u679c\u5f53\u524d\u8fd0\u884c\u7684\u7ebf\u7a0b\u6570\u5df2\u7ecf\u8fbe\u5230\u4e86\u9650\u5236\uff0c\u7ebf\u7a0b\u5c06\u4f1a\u963b\u585e\uff0c\u76f4\u5230\u6709\u5176\u4ed6\u7ebf\u7a0b\u91ca\u653eSemaphore\u5bf9\u8c61\u3002<\/p>\n<\/p>\n<p><h3>Queue<\/h3>\n<\/p>\n<p><p><strong>Queue\u662fPython queue\u6a21\u5757\u4e2d\u7684\u4e00\u4e2a\u7c7b\uff0c\u7528\u4e8e\u5728\u7ebf\u7a0b\u4e4b\u95f4\u4f20\u9012\u6570\u636e\u3002<\/strong>\u5b83\u4e5f\u53ef\u4ee5\u88ab\u7528\u6765\u63a7\u5236\u591a\u7ebf\u7a0b\u7684\u6570\u91cf\u3002\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528Queue\u6765\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>import queue<\/p>\n<p>import time<\/p>\n<p>def worker(q):<\/p>\n<p>    while True:<\/p>\n<p>        item = q.get()<\/p>\n<p>        if item is None:<\/p>\n<p>            break<\/p>\n<p>        print(f&#39;Task {item} is running&#39;)<\/p>\n<p>        time.sleep(2)<\/p>\n<p>        print(f&#39;Task {item} is completed&#39;)<\/p>\n<p>        q.task_done()<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2aQueue\u5bf9\u8c61<\/strong><\/h2>\n<p>q = queue.Queue()<\/p>\n<p>threads = []<\/p>\n<h2><strong>\u521b\u5efa3\u4e2a\u5de5\u4f5c\u7ebf\u7a0b<\/strong><\/h2>\n<p>for i in range(3):<\/p>\n<p>    t = threading.Thread(target=worker, args=(q,))<\/p>\n<p>    t.start()<\/p>\n<p>    threads.append(t)<\/p>\n<h2><strong>\u5411Queue\u4e2d\u6dfb\u52a010\u4e2a\u4efb\u52a1<\/strong><\/h2>\n<p>for item in range(10):<\/p>\n<p>    q.put(item)<\/p>\n<h2><strong>\u7b49\u5f85\u6240\u6709\u4efb\u52a1\u5b8c\u6210<\/strong><\/h2>\n<p>q.join()<\/p>\n<h2><strong>\u505c\u6b62\u6240\u6709\u5de5\u4f5c\u7ebf\u7a0b<\/strong><\/h2>\n<p>for i in range(3):<\/p>\n<p>    q.put(None)<\/p>\n<p>for t in threads:<\/p>\n<p>    t.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2aQueue\u5bf9\u8c61\u548c3\u4e2a\u5de5\u4f5c\u7ebf\u7a0b\u3002\u6bcf\u4e2a\u5de5\u4f5c\u7ebf\u7a0b\u4f1a\u4eceQueue\u4e2d\u83b7\u53d6\u4e00\u4e2a\u4efb\u52a1\u8fdb\u884c\u5904\u7406\uff0c\u5982\u679cQueue\u4e3a\u7a7a\uff0c\u7ebf\u7a0b\u4f1a\u963b\u585e\uff0c\u76f4\u5230\u6709\u65b0\u7684\u4efb\u52a1\u52a0\u5165Queue\u3002\u901a\u8fc7\u63a7\u5236\u5de5\u4f5c\u7ebf\u7a0b\u7684\u6570\u91cf\uff0c\u6211\u4eec\u53ef\u4ee5\u63a7\u5236\u5e76\u53d1\u7ebf\u7a0b\u7684\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><h3>\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u6c60<\/h3>\n<\/p>\n<p><p><strong>\u901a\u8fc7\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u6c60\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u52a0\u7075\u6d3b\u5730\u63a7\u5236\u591a\u7ebf\u7a0b\u7684\u6570\u91cf\u548c\u884c\u4e3a\u3002<\/strong>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u6c60\u7684\u4f8b\u5b50\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>import queue<\/p>\n<p>import time<\/p>\n<p>class ThreadPool:<\/p>\n<p>    def __init__(self, num_threads):<\/p>\n<p>        self.tasks = queue.Queue()<\/p>\n<p>        self.threads = []<\/p>\n<p>        for _ in range(num_threads):<\/p>\n<p>            t = threading.Thread(target=self.worker)<\/p>\n<p>            t.start()<\/p>\n<p>            self.threads.append(t)<\/p>\n<p>    def worker(self):<\/p>\n<p>        while True:<\/p>\n<p>            func, args, kwargs = self.tasks.get()<\/p>\n<p>            if func is None:<\/p>\n<p>                break<\/p>\n<p>            func(*args, kwargs)<\/p>\n<p>            self.tasks.task_done()<\/p>\n<p>    def add_task(self, func, *args, kwargs):<\/p>\n<p>        self.tasks.put((func, args, kwargs))<\/p>\n<p>    def w<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>t_completion(self):<\/p>\n<p>        self.tasks.join()<\/p>\n<p>        for _ in range(len(self.threads)):<\/p>\n<p>            self.tasks.put((None, (), {}))<\/p>\n<p>        for t in self.threads:<\/p>\n<p>            t.join()<\/p>\n<p>def task(name):<\/p>\n<p>    print(f&#39;Task {name} is running&#39;)<\/p>\n<p>    time.sleep(2)<\/p>\n<p>    print(f&#39;Task {name} is completed&#39;)<\/p>\n<h2><strong>\u521b\u5efa\u4e00\u4e2a\u5305\u542b3\u4e2a\u7ebf\u7a0b\u7684\u7ebf\u7a0b\u6c60<\/strong><\/h2>\n<p>pool = ThreadPool(3)<\/p>\n<h2><strong>\u5411\u7ebf\u7a0b\u6c60\u4e2d\u6dfb\u52a010\u4e2a\u4efb\u52a1<\/strong><\/h2>\n<p>for i in range(10):<\/p>\n<p>    pool.add_task(task, i)<\/p>\n<h2><strong>\u7b49\u5f85\u6240\u6709\u4efb\u52a1\u5b8c\u6210<\/strong><\/h2>\n<p>pool.wait_completion()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5b9a\u4e49\u4e86\u4e00\u4e2aThreadPool\u7c7b\uff0c\u7528\u4e8e\u7ba1\u7406\u7ebf\u7a0b\u6c60\u548c\u4efb\u52a1\u961f\u5217\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u521b\u5efaThreadPool\u5bf9\u8c61\u5e76\u5411\u5176\u6dfb\u52a0\u4efb\u52a1\u6765\u63a7\u5236\u591a\u7ebf\u7a0b\u7684\u6570\u91cf\u3002\u7ebf\u7a0b\u6c60\u4f1a\u81ea\u52a8\u7ba1\u7406\u7ebf\u7a0b\u7684\u521b\u5efa\u548c\u9500\u6bc1\uff0c\u5e76\u786e\u4fdd\u540c\u65f6\u8fd0\u884c\u7684\u7ebf\u7a0b\u6570\u91cf\u4e0d\u4f1a\u8d85\u8fc7\u6307\u5b9a\u7684\u6570\u91cf\u3002<\/p>\n<\/p>\n<p><h3>\u5c0f\u7ed3<\/h3>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u51e0\u79cd\u65b9\u6cd5\uff0c\u6211\u4eec\u53ef\u4ee5\u65b9\u4fbf\u5730\u63a7\u5236Python\u4e2d\u7684\u591a\u7ebf\u7a0b\u6570\u91cf\u3002<strong>ThreadPoolExecutor<\/strong>\u662f\u6700\u5e38\u7528\u4e14\u65b9\u4fbf\u7684\u4e00\u79cd\u65b9\u6cd5\uff0c\u800c<strong>Semaphore<\/strong>\u548c<strong>Queue<\/strong>\u5219\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u7075\u6d3b\u6027\u548c\u63a7\u5236\u3002<strong>\u81ea\u5b9a\u4e49\u7ebf\u7a0b\u6c60<\/strong>\u53ef\u4ee5\u6ee1\u8db3\u4e00\u4e9b\u7279\u6b8a\u9700\u6c42\uff0c\u9002\u5408\u66f4\u590d\u6742\u7684\u5e94\u7528\u573a\u666f\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\uff0c\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u6548\u7387\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bbe\u7f6e\u7ebf\u7a0b\u7684\u6700\u5927\u6570\u91cf\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>threading<\/code>\u6a21\u5757\u7684<code>ThreadPoolExecutor<\/code>\u6765\u63a7\u5236\u7ebf\u7a0b\u7684\u6700\u5927\u6570\u91cf\u3002\u901a\u8fc7\u8bbe\u7f6e<code>max_workers<\/code>\u53c2\u6570\uff0c\u60a8\u53ef\u4ee5\u9650\u5236\u540c\u65f6\u8fd0\u884c\u7684\u7ebf\u7a0b\u6570\u91cf\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a<code>ThreadPoolExecutor<\/code>\u5b9e\u4f8b\uff0c\u5e76\u5728\u5b9e\u4f8b\u5316\u65f6\u6307\u5b9a\u6700\u5927\u7ebf\u7a0b\u6570\uff0c\u4ece\u800c\u907f\u514d\u7cfb\u7edf\u8d44\u6e90\u7684\u8fc7\u5ea6\u6d88\u8017\u3002<\/p>\n<p><strong>Python\u4e2d\u591a\u7ebf\u7a0b\u7684\u4f18\u7f3a\u70b9\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u591a\u7ebf\u7a0b\u5728Python\u4e2d\u7684\u4e3b\u8981\u4f18\u70b9\u662f\u80fd\u591f\u63d0\u9ad8\u7a0b\u5e8f\u7684\u54cd\u5e94\u901f\u5ea6\u548c\u6267\u884c\u6548\u7387\uff0c\u7279\u522b\u662f\u5728\u5904\u7406I\/O\u5bc6\u96c6\u578b\u4efb\u52a1\u65f6\u3002\u7f3a\u70b9\u5219\u5305\u62ec\u5168\u5c40\u89e3\u91ca\u5668\u9501\uff08GIL\uff09\u7684\u5b58\u5728\uff0c\u8fd9\u53ef\u80fd\u5bfc\u81f4CPU\u5bc6\u96c6\u578b\u4efb\u52a1\u4e0d\u80fd\u5145\u5206\u5229\u7528\u591a\u6838\u5904\u7406\u5668\u7684\u4f18\u52bf\u3002\u56e0\u6b64\uff0c\u5728\u9009\u62e9\u4f7f\u7528\u591a\u7ebf\u7a0b\u65f6\uff0c\u9700\u8003\u8651\u4efb\u52a1\u7c7b\u578b\u548c\u6027\u80fd\u9700\u6c42\u3002<\/p>\n<p><strong>\u5982\u4f55\u76d1\u63a7\u548c\u7ba1\u7406Python\u4e2d\u7684\u7ebf\u7a0b\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7<code>threading<\/code>\u6a21\u5757\u63d0\u4f9b\u7684\u4e00\u4e9b\u5de5\u5177\u6765\u76d1\u63a7\u548c\u7ba1\u7406\u7ebf\u7a0b\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>threading.active_count()<\/code>\u53ef\u4ee5\u83b7\u53d6\u5f53\u524d\u6d3b\u52a8\u7ebf\u7a0b\u7684\u6570\u91cf\uff0c<code>threading.enumerate()<\/code>\u53ef\u4ee5\u5217\u51fa\u6240\u6709\u6d3b\u8dc3\u7684\u7ebf\u7a0b\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>join()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u786e\u4fdd\u4e3b\u7a0b\u5e8f\u7b49\u5f85\u7ebf\u7a0b\u6267\u884c\u5b8c\u6210\uff0c\u4ece\u800c\u66f4\u597d\u5730\u7ba1\u7406\u7ebf\u7a0b\u7684\u751f\u547d\u5468\u671f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u63a7\u5236\u591a\u7ebf\u7a0b\u6570\u91cf\u7684\u65b9\u6cd5\u5305\u62ec\u4f7f\u7528ThreadPoolExecutor\u3001Semaphore\u3001Queue\u3001 [&hellip;]","protected":false},"author":3,"featured_media":1170696,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170690"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1170690"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170690\/revisions"}],"predecessor-version":[{"id":1170699,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1170690\/revisions\/1170699"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1170696"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1170690"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1170690"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1170690"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}