{"id":1134196,"date":"2025-01-08T21:13:37","date_gmt":"2025-01-08T13:13:37","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1134196.html"},"modified":"2025-01-08T21:13:39","modified_gmt":"2025-01-08T13:13:39","slug":"%e5%9c%a8python%e4%b8%ad%e5%a6%82%e4%bd%95%e8%af%bb%e5%8f%96%e6%96%87%e4%bb%b6%e5%a4%b9%e7%9a%84%e5%9b%be%e7%89%87","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1134196.html","title":{"rendered":"\u5728python\u4e2d\u5982\u4f55\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25103148\/6b25810f-bdfa-45df-9358-3b3799be9533.webp\" alt=\"\u5728python\u4e2d\u5982\u4f55\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\" \/><\/p>\n<p><p> \u5728Python\u4e2d\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u591a\u79cd\u4e0d\u540c\u7684\u5e93\u6765\u5b9e\u73b0\uff0c\u5e38\u7528\u7684\u5305\u62ec<strong>os\u5e93<\/strong>\u3001<strong>glob\u5e93<\/strong>\u548c<strong>Pillow\u5e93<\/strong>\u7b49\u3002\u8fd9\u4e9b\u5e93\u5404\u6709\u4f18\u52a3\uff0c\u9009\u62e9\u5408\u9002\u7684\u5e93\u53ef\u4ee5\u7b80\u5316\u4f60\u7684\u4ee3\u7801\uff0c\u5e76\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u6548\u7387\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e9b\u5e93\u6765\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\u3002<\/p>\n<\/p>\n<h2><strong>\u4e00\u3001PYTHON\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u5e38\u7528\u65b9\u6cd5<\/strong><\/h2>\n<p><p>\u5728Python\u4e2d\uff0c\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\u4e3b\u8981\u6709\u4ee5\u4e0b\u51e0\u79cd\u65b9\u6cd5\uff1a<strong>\u4f7f\u7528os\u5e93\u904d\u5386\u6587\u4ef6\u5939\u3001\u4f7f\u7528glob\u5e93\u67e5\u627e\u7279\u5b9a\u6587\u4ef6\u7c7b\u578b\u3001\u4f7f\u7528Pillow\u5e93\u8bfb\u53d6\u548c\u5904\u7406\u56fe\u50cf\u3001\u7ed3\u5408\u591a\u79cd\u5e93\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u64cd\u4f5c<\/strong>\u3002\u8fd9\u4e9b\u65b9\u6cd5\u5404\u6709\u4f18\u52a3\uff0c\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5b9e\u73b0\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u4f7f\u7528os\u5e93\u904d\u5386\u6587\u4ef6\u5939<\/h2>\n<\/p>\n<p><p><strong>os\u5e93<\/strong>\u662fPython\u6807\u51c6\u5e93\u4e2d\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u4e3b\u8981\u7528\u4e8e\u4e0e\u64cd\u4f5c\u7cfb\u7edf\u8fdb\u884c\u4ea4\u4e92\u3002\u901a\u8fc7os\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u904d\u5386\u6587\u4ef6\u5939\u5e76\u8bfb\u53d6\u5176\u4e2d\u7684\u56fe\u7247\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def read_images_from_folder(folder_path):<\/p>\n<p>    images = []<\/p>\n<p>    for filename in os.listdir(folder_path):<\/p>\n<p>        if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            images.append(img)<\/p>\n<p>    return images<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>images = read_images_from_folder(folder_path)<\/p>\n<p>for img in images:<\/p>\n<p>    img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u904d\u5386\u6307\u5b9a\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\uff0c\u5e76\u901a\u8fc7\u6587\u4ef6\u6269\u5c55\u540d\u7b5b\u9009\u51fa\u56fe\u7247\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528Pillow\u5e93\u4e2d\u7684Image.open()\u51fd\u6570\u6253\u5f00\u56fe\u7247\u6587\u4ef6\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u4f7f\u7528glob\u5e93\u67e5\u627e\u7279\u5b9a\u6587\u4ef6\u7c7b\u578b<\/h2>\n<\/p>\n<p><p><strong>glob\u5e93<\/strong>\u662fPython\u6807\u51c6\u5e93\u4e2d\u7684\u53e6\u4e00\u4e2a\u6a21\u5757\uff0c\u4e3b\u8981\u7528\u4e8e\u67e5\u627e\u7b26\u5408\u7279\u5b9a\u6a21\u5f0f\u7684\u6587\u4ef6\u8def\u5f84\u3002\u76f8\u6bd4\u4e8eos\u5e93\uff0cglob\u5e93\u53ef\u4ee5\u66f4\u52a0\u65b9\u4fbf\u5730\u67e5\u627e\u7279\u5b9a\u7c7b\u578b\u7684\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import glob<\/p>\n<p>from PIL import Image<\/p>\n<p>def read_images_from_folder(folder_path):<\/p>\n<p>    images = []<\/p>\n<p>    for filepath in glob.glob(os.path.join(folder_path, &quot;*.jpg&quot;)) + glob.glob(os.path.join(folder_path, &quot;*.png&quot;)):<\/p>\n<p>        img = Image.open(filepath)<\/p>\n<p>        images.append(img)<\/p>\n<p>    return images<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>images = read_images_from_folder(folder_path)<\/p>\n<p>for img in images:<\/p>\n<p>    img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528glob\u5e93\u67e5\u627e\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709jpg\u548cpng\u683c\u5f0f\u7684\u56fe\u7247\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528Pillow\u5e93\u4e2d\u7684Image.open()\u51fd\u6570\u6253\u5f00\u56fe\u7247\u6587\u4ef6\u5e76\u5c06\u5176\u5b58\u50a8\u5728\u5217\u8868\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u4f7f\u7528Pillow\u5e93\u8bfb\u53d6\u548c\u5904\u7406\u56fe\u50cf<\/h2>\n<\/p>\n<p><p><strong>Pillow\u5e93<\/strong>\u662fPython\u4e2d\u4e00\u4e2a\u5f3a\u5927\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u53ef\u4ee5\u7528\u4e8e\u6253\u5f00\u3001\u64cd\u4f5c\u548c\u4fdd\u5b58\u5404\u79cd\u683c\u5f0f\u7684\u56fe\u50cf\u6587\u4ef6\u3002\u901a\u8fc7Pillow\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u8bfb\u53d6\u548c\u5904\u7406\u56fe\u50cf\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<p>def read_image(image_path):<\/p>\n<p>    img = Image.open(image_path)<\/p>\n<p>    return img<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>image_path = &quot;path\/to\/your\/image.jpg&quot;<\/p>\n<p>img = read_image(image_path)<\/p>\n<p>img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Pillow\u5e93\u4e2d\u7684Image.open()\u51fd\u6570\u6253\u5f00\u6307\u5b9a\u8def\u5f84\u7684\u56fe\u7247\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528Image\u5bf9\u8c61\u7684show()\u65b9\u6cd5\u663e\u793a\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h2>4\u3001\u7ed3\u5408\u591a\u79cd\u5e93\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u64cd\u4f5c<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u7ed3\u5408\u591a\u79cd\u5e93\u6765\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed3\u5408os\u5e93\u548cPillow\u5e93\uff0c\u5b9e\u73b0\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\u5e76\u5bf9\u5176\u8fdb\u884c\u6279\u91cf\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def read_and_process_images(folder_path, output_folder):<\/p>\n<p>    if not os.path.exists(output_folder):<\/p>\n<p>        os.makedirs(output_folder)<\/p>\n<p>    for filename in os.listdir(folder_path):<\/p>\n<p>        if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            img = img.convert(&quot;L&quot;)  # \u5c06\u56fe\u7247\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe<\/p>\n<p>            img.save(os.path.join(output_folder, filename))<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>output_folder = &quot;path\/to\/output\/folder&quot;<\/p>\n<p>read_and_process_images(folder_path, output_folder)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u904d\u5386\u6307\u5b9a\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u56fe\u7247\u6587\u4ef6\uff0c\u5c06\u5176\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe\u50cf\uff0c\u5e76\u5c06\u5904\u7406\u540e\u7684\u56fe\u7247\u4fdd\u5b58\u5230\u6307\u5b9a\u7684\u8f93\u51fa\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<\/p>\n<h2><strong>\u4e8c\u3001PYTHON\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u8be6\u7ec6\u6b65\u9aa4<\/strong><\/h2>\n<p><p>\u5728\u8fd9\u4e00\u90e8\u5206\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecdPython\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u5177\u4f53\u6b65\u9aa4\uff0c\u5305\u62ec<strong>\u73af\u5883\u914d\u7f6e\u3001\u5e93\u7684\u5b89\u88c5\u3001\u4ee3\u7801\u5b9e\u73b0\u548c\u4f18\u5316<\/strong>\u3002\u901a\u8fc7\u8fd9\u4e9b\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u548c\u638c\u63e1\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u73af\u5883\u914d\u7f6e<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u7f16\u7801\u4e4b\u524d\uff0c\u6211\u4eec\u9700\u8981\u8fdb\u884c\u4e00\u4e9b\u73af\u5883\u914d\u7f6e\u5de5\u4f5c\uff0c\u786e\u4fddPython\u548c\u76f8\u5173\u5e93\u5df2\u7ecf\u5b89\u88c5\u5e76\u914d\u7f6e\u6b63\u786e\u3002<\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Python<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b89\u88c5Python\u3002\u5982\u679c\u4f60\u8fd8\u6ca1\u6709\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u4ecePython\u5b98\u7f51\uff08<a href=\"https:\/\/www.python.org\/%EF%BC%89%E4%B8%8B%E8%BD%BD%E5%B9%B6%E5%AE%89%E8%A3%85%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84Python%E3%80%82\">https:\/\/www.python.org\/\uff09\u4e0b\u8f7d\u5e76\u5b89\u88c5\u6700\u65b0\u7248\u672c\u7684Python\u3002<\/a><\/p>\n<\/p>\n<p><h3>\u5b89\u88c5Pillow\u5e93<\/h3>\n<\/p>\n<p><p>Pillow\u5e93\u662fPython\u4e2d\u5e38\u7528\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7pip\u547d\u4ee4\u5b89\u88c5Pillow\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install pillow<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>2\u3001\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u4ee3\u7801\u5b9e\u73b0<\/h2>\n<\/p>\n<p><p>\u5728\u73af\u5883\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5f00\u59cb\u7f16\u5199\u4ee3\u7801\uff0c\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528os\u5e93\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def read_images_from_folder(folder_path):<\/p>\n<p>    images = []<\/p>\n<p>    for filename in os.listdir(folder_path):<\/p>\n<p>        if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            images.append(img)<\/p>\n<p>    return images<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>images = read_images_from_folder(folder_path)<\/p>\n<p>for img in images:<\/p>\n<p>    img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4f7f\u7528glob\u5e93\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import glob<\/p>\n<p>from PIL import Image<\/p>\n<p>def read_images_from_folder(folder_path):<\/p>\n<p>    images = []<\/p>\n<p>    for filepath in glob.glob(os.path.join(folder_path, &quot;*.jpg&quot;)) + glob.glob(os.path.join(folder_path, &quot;*.png&quot;)):<\/p>\n<p>        img = Image.open(filepath)<\/p>\n<p>        images.append(img)<\/p>\n<p>    return images<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>images = read_images_from_folder(folder_path)<\/p>\n<p>for img in images:<\/p>\n<p>    img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u7ed3\u5408os\u5e93\u548cPillow\u5e93\u5b9e\u73b0\u6279\u91cf\u5904\u7406<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def read_and_process_images(folder_path, output_folder):<\/p>\n<p>    if not os.path.exists(output_folder):<\/p>\n<p>        os.makedirs(output_folder)<\/p>\n<p>    for filename in os.listdir(folder_path):<\/p>\n<p>        if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            img = img.convert(&quot;L&quot;)  # \u5c06\u56fe\u7247\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe<\/p>\n<p>            img.save(os.path.join(output_folder, filename))<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>output_folder = &quot;path\/to\/output\/folder&quot;<\/p>\n<p>read_and_process_images(folder_path, output_folder)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>3\u3001\u4ee3\u7801\u4f18\u5316<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u5bf9\u4ee3\u7801\u8fdb\u884c\u4e00\u4e9b\u4f18\u5316\uff0c\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u8fd0\u884c\u6548\u7387\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u4ee3\u7801\u5c01\u88c5\u6210\u4e00\u4e2a\u7c7b\uff0c\u4fbf\u4e8e\u4ee3\u7801\u7684\u590d\u7528\u548c\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>class ImageReader:<\/p>\n<p>    def __init__(self, folder_path):<\/p>\n<p>        self.folder_path = folder_path<\/p>\n<p>    def read_images(self):<\/p>\n<p>        images = []<\/p>\n<p>        for filename in os.listdir(self.folder_path):<\/p>\n<p>            if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>                img = Image.open(os.path.join(self.folder_path, filename))<\/p>\n<p>                images.append(img)<\/p>\n<p>        return images<\/p>\n<p>    def read_and_process_images(self, output_folder):<\/p>\n<p>        if not os.path.exists(output_folder):<\/p>\n<p>            os.makedirs(output_folder)<\/p>\n<p>        for filename in os.listdir(self.folder_path):<\/p>\n<p>            if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>                img = Image.open(os.path.join(self.folder_path, filename))<\/p>\n<p>                img = img.convert(&quot;L&quot;)  # \u5c06\u56fe\u7247\u8f6c\u6362\u4e3a\u7070\u5ea6\u56fe<\/p>\n<p>                img.save(os.path.join(output_folder, filename))<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>image_reader = ImageReader(folder_path)<\/p>\n<p>images = image_reader.read_images()<\/p>\n<p>for img in images:<\/p>\n<p>    img.show()<\/p>\n<p>output_folder = &quot;path\/to\/output\/folder&quot;<\/p>\n<p>image_reader.read_and_process_images(output_folder)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u5c06\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u529f\u80fd\u5c01\u88c5\u6210\u4e00\u4e2aImageReader\u7c7b\uff0c\u4fbf\u4e8e\u4ee3\u7801\u7684\u590d\u7528\u548c\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<h2><strong>\u4e09\u3001PYTHON\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u5e94\u7528\u573a\u666f<\/strong><\/h2>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\u662f\u4e00\u4e2a\u975e\u5e38\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u5c24\u5176\u662f\u5728<strong>\u56fe\u50cf\u5904\u7406\u3001\u8ba1\u7b97\u673a\u89c6\u89c9\u548c<a href=\"https:\/\/docs.pingcode.com\/ask\/59192.html\" target=\"_blank\">\u673a\u5668\u5b66\u4e60<\/a><\/strong>\u7b49\u9886\u57df\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u51e0\u4e2a\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u56fe\u50cf\u6279\u91cf\u5904\u7406<\/h2>\n<\/p>\n<p><p>\u5728\u56fe\u50cf\u5904\u7406\u9886\u57df\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u5bf9\u5927\u91cf\u56fe\u7247\u8fdb\u884c\u6279\u91cf\u5904\u7406\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u5bf9\u4e00\u6279\u56fe\u7247\u8fdb\u884c<strong>\u683c\u5f0f\u8f6c\u6362\u3001\u5927\u5c0f\u8c03\u6574\u3001\u989c\u8272\u7a7a\u95f4\u8f6c\u6362<\/strong>\u7b49\u64cd\u4f5c\u3002\u901a\u8fc7Python\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u8fd9\u4e9b\u6279\u91cf\u5904\u7406\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def batch_process_images(folder_path, output_folder):<\/p>\n<p>    if not os.path.exists(output_folder):<\/p>\n<p>        os.makedirs(output_folder)<\/p>\n<p>    for filename in os.listdir(folder_path):<\/p>\n<p>        if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            img = img.resize((256, 256))  # \u8c03\u6574\u56fe\u7247\u5927\u5c0f<\/p>\n<p>            img.save(os.path.join(output_folder, filename))<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>output_folder = &quot;path\/to\/output\/folder&quot;<\/p>\n<p>batch_process_images(folder_path, output_folder)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6307\u5b9a\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u56fe\u7247\u5927\u5c0f\u8c03\u6574\u4e3a256&#215;256\u50cf\u7d20\uff0c\u5e76\u5c06\u5904\u7406\u540e\u7684\u56fe\u7247\u4fdd\u5b58\u5230\u6307\u5b9a\u7684\u8f93\u51fa\u6587\u4ef6\u5939\u4e2d\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u6570\u636e\u9884\u5904\u7406<\/h2>\n<\/p>\n<p><p>\u5728\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u673a\u5668\u5b66\u4e60\u9886\u57df\uff0c\u6211\u4eec\u7ecf\u5e38\u9700\u8981\u5bf9\u56fe\u7247\u6570\u636e\u8fdb\u884c\u9884\u5904\u7406\uff0c\u4ee5\u4fbf\u7528\u4e8e\u6a21\u578b\u8bad\u7ec3\u548c\u8bc4\u4f30\u3002\u901a\u8fc7Python\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u6570\u636e\u9884\u5904\u7406\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>import numpy as np<\/p>\n<p>from PIL import Image<\/p>\n<p>def preprocess_images(folder_path):<\/p>\n<p>    image_data = []<\/p>\n<p>    for filename in os.listdir(folder_path):<\/p>\n<p>        if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            img = img.resize((128, 128))  # \u8c03\u6574\u56fe\u7247\u5927\u5c0f<\/p>\n<p>            img_array = np.array(img) \/ 255.0  # \u5c06\u56fe\u7247\u8f6c\u6362\u4e3a\u6570\u7ec4\u5e76\u5f52\u4e00\u5316<\/p>\n<p>            image_data.append(img_array)<\/p>\n<p>    return np.array(image_data)<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>image_data = preprocess_images(folder_path)<\/p>\n<p>print(image_data.shape)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6307\u5b9a\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u56fe\u7247\u8c03\u6574\u4e3a128&#215;128\u50cf\u7d20\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u5f52\u4e00\u5316\u7684\u6570\u7ec4\u5f62\u5f0f\uff0c\u4ee5\u4fbf\u7528\u4e8e\u6a21\u578b\u8bad\u7ec3\u548c\u8bc4\u4f30\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u56fe\u50cf\u5206\u7c7b<\/h2>\n<\/p>\n<p><p>\u5728\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u4e2d\uff0c\u6211\u4eec\u901a\u5e38\u9700\u8981\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\u6570\u636e\uff0c\u5e76\u5c06\u5176\u5206\u914d\u5230\u4e0d\u540c\u7684\u7c7b\u522b\u3002\u901a\u8fc7Python\u8bfb\u53d6\u6587\u4ef6\u5939\u4e2d\u7684\u56fe\u7247\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def load_dataset(dataset_path):<\/p>\n<p>    data = []<\/p>\n<p>    labels = []<\/p>\n<p>    for category in os.listdir(dataset_path):<\/p>\n<p>        category_path = os.path.join(dataset_path, category)<\/p>\n<p>        if os.path.isdir(category_path):<\/p>\n<p>            for filename in os.listdir(category_path):<\/p>\n<p>                if filename.endswith(&quot;.jpg&quot;) or filename.endswith(&quot;.png&quot;):<\/p>\n<p>                    img = Image.open(os.path.join(category_path, filename))<\/p>\n<p>                    img = img.resize((128, 128))  # \u8c03\u6574\u56fe\u7247\u5927\u5c0f<\/p>\n<p>                    data.append(np.array(img))<\/p>\n<p>                    labels.append(category)<\/p>\n<p>    return np.array(data), np.array(labels)<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>dataset_path = &quot;path\/to\/your\/dataset&quot;<\/p>\n<p>data, labels = load_dataset(dataset_path)<\/p>\n<p>print(data.shape, labels.shape)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u6307\u5b9a\u6570\u636e\u96c6\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u56fe\u7247\u6570\u636e\u548c\u6807\u7b7e\u52a0\u8f7d\u5230\u5185\u5b58\u4e2d\uff0c\u4ee5\u4fbf\u7528\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\u3002<\/p>\n<\/p>\n<h2><strong>\u56db\u3001\u5e38\u89c1\u95ee\u9898\u53ca\u89e3\u51b3\u65b9\u6cd5<\/strong><\/h2>\n<p><p>\u5728Python\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd\u51e0\u4e2a\u5e38\u89c1\u95ee\u9898\u53ca\u5176\u89e3\u51b3\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><h2>1\u3001\u6587\u4ef6\u8def\u5f84\u9519\u8bef<\/h2>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u65f6\uff0c\u6587\u4ef6\u8def\u5f84\u9519\u8bef\u662f\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\u3002\u4e3a\u4e86\u907f\u514d\u6587\u4ef6\u8def\u5f84\u9519\u8bef\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528os.path.join()\u51fd\u6570\u6765\u62fc\u63a5\u6587\u4ef6\u8def\u5f84\uff0c\u4ece\u800c\u786e\u4fdd\u8def\u5f84\u7684\u6b63\u786e\u6027\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>filename = &quot;image.jpg&quot;<\/p>\n<p>file_path = os.path.join(folder_path, filename)<\/p>\n<p>print(file_path)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u786e\u4fdd\u62fc\u63a5\u540e\u7684\u6587\u4ef6\u8def\u5f84\u662f\u6b63\u786e\u7684\u3002<\/p>\n<\/p>\n<p><h2>2\u3001\u6587\u4ef6\u683c\u5f0f\u4e0d\u652f\u6301<\/h2>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u56fe\u7247\u6587\u4ef6\u65f6\uff0c\u6587\u4ef6\u683c\u5f0f\u4e0d\u652f\u6301\u662f\u53e6\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\u3002\u4e3a\u4e86\u786e\u4fdd\u6587\u4ef6\u683c\u5f0f\u652f\u6301\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Pillow\u5e93\u4e2d\u7684Image.open()\u51fd\u6570\uff0c\u5e76\u5728\u8bfb\u53d6\u6587\u4ef6\u65f6\u8fdb\u884c\u5f02\u5e38\u5904\u7406\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from PIL import Image<\/p>\n<p>def read_image(image_path):<\/p>\n<p>    try:<\/p>\n<p>        img = Image.open(image_path)<\/p>\n<p>        return img<\/p>\n<p>    except IOError:<\/p>\n<p>        print(f&quot;\u65e0\u6cd5\u6253\u5f00\u6587\u4ef6: {image_path}&quot;)<\/p>\n<p>        return None<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>image_path = &quot;path\/to\/your\/image.jpg&quot;<\/p>\n<p>img = read_image(image_path)<\/p>\n<p>if img:<\/p>\n<p>    img.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8bfb\u53d6\u56fe\u7247\u6587\u4ef6\u65f6\u8fdb\u884c\u5f02\u5e38\u5904\u7406\uff0c\u4ece\u800c\u907f\u514d\u6587\u4ef6\u683c\u5f0f\u4e0d\u652f\u6301\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<p><h2>3\u3001\u5185\u5b58\u4e0d\u8db3<\/h2>\n<\/p>\n<p><p>\u5728\u8bfb\u53d6\u5927\u91cf\u56fe\u7247\u6570\u636e\u65f6\uff0c\u5185\u5b58\u4e0d\u8db3\u662f\u4e00\u4e2a\u5e38\u89c1\u95ee\u9898\u3002\u4e3a\u4e86\u907f\u514d\u5185\u5b58\u4e0d\u8db3\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8bfb\u53d6\u56fe\u7247\u6570\u636e\u65f6\u8fdb\u884c\u6279\u5904\u7406\uff0c\u5e76\u5728\u5904\u7406\u5b8c\u4e00\u6279\u56fe\u7247\u540e\u91ca\u653e\u5185\u5b58\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import os<\/p>\n<p>from PIL import Image<\/p>\n<p>def batch_process_images(folder_path, batch_size=100):<\/p>\n<p>    filenames = [f for f in os.listdir(folder_path) if f.endswith(&quot;.jpg&quot;) or f.endswith(&quot;.png&quot;)]<\/p>\n<p>    for i in range(0, len(filenames), batch_size):<\/p>\n<p>        batch_filenames = filenames[i:i+batch_size]<\/p>\n<p>        for filename in batch_filenames:<\/p>\n<p>            img = Image.open(os.path.join(folder_path, filename))<\/p>\n<p>            img = img.resize((256, 256))  # \u8c03\u6574\u56fe\u7247\u5927\u5c0f<\/p>\n<p>            img.show()<\/p>\n<p>        # \u91ca\u653e\u5185\u5b58<\/p>\n<p>        del img<\/p>\n<h2><strong>\u793a\u4f8b\u4f7f\u7528<\/strong><\/h2>\n<p>folder_path = &quot;path\/to\/your\/folder&quot;<\/p>\n<p>batch_process_images(folder_path)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u4e0a\u8ff0\u4ee3\u7801\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u8bfb\u53d6\u5927\u91cf\u56fe\u7247\u6570\u636e\u65f6\u8fdb\u884c\u6279\u5904\u7406\uff0c\u4ece\u800c\u907f\u514d\u5185\u5b58\u4e0d\u8db3\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<h2><strong>\u603b\u7ed3<\/strong><\/h2>\n<p><p>\u5728Python\u4e2d\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\u662f\u4e00\u4e2a\u975e\u5e38\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u5c24\u5176\u662f\u5728\u56fe\u50cf\u5904\u7406\u3001\u8ba1\u7b97\u673a\u89c6\u89c9\u548c\u673a\u5668\u5b66\u4e60\u7b49\u9886\u57df\u3002\u901a\u8fc7\u4f7f\u7528os\u5e93\u3001glob\u5e93\u548cPillow\u5e93\u7b49\u5e38\u7528\u5e93\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5b9e\u73b0\u8bfb\u53d6\u6587\u4ef6\u5939\u56fe\u7247\u7684\u529f\u80fd\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u7ed3\u5408\u591a\u79cd\u5e93\u548c\u6280\u672f\u5b9e\u73b0\u66f4\u590d\u6742\u7684\u64cd\u4f5c\uff0c\u5e76\u5bf9\u4ee3\u7801\u8fdb\u884c\u4f18\u5316\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u8fd0\u884c\u6548\u7387\u3002\u5e0c\u671b\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u4f60\u80fd\u591f\u66f4\u597d\u5730\u7406\u89e3\u548c\u638c\u63e1\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\uff0c\u5e76\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\u7075\u6d3b\u8fd0\u7528\u8fd9\u4e9b\u6280\u672f\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u8bfb\u53d6\u7279\u5b9a\u7c7b\u578b\u7684\u56fe\u7247\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528<code>os<\/code>\u5e93\u548c<code>PIL<\/code>\uff08Pillow\uff09\u5e93\u6765\u8bfb\u53d6\u7279\u5b9a\u7c7b\u578b\u7684\u56fe\u7247\u6587\u4ef6\uff0c\u6bd4\u5982JPEG\u6216PNG\u3002\u901a\u8fc7<code>os.listdir()<\/code>\u51fd\u6570\u53ef\u4ee5\u5217\u51fa\u6587\u4ef6\u5939\u4e2d\u7684\u6240\u6709\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u7528<code>PIL.Image.open()<\/code>\u6253\u5f00\u7b26\u5408\u7279\u5b9a\u6269\u5c55\u540d\u7684\u56fe\u7247\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u904d\u5386\u6587\u4ef6\u5939\u4e2d\u7684\u6bcf\u4e2a\u6587\u4ef6\uff0c\u68c0\u67e5\u5176\u6269\u5c55\u540d\u662f\u5426\u4e3a<code>.jpg<\/code>\u6216<code>.png<\/code>\uff0c\u5e76\u5c06\u5176\u52a0\u8f7d\u5230\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u5904\u7406\u3002<\/p>\n<p><strong>\u5982\u4f55\u5904\u7406\u8bfb\u53d6\u5230\u7684\u56fe\u7247\u6570\u636e\uff1f<\/strong><br \/>\u8bfb\u53d6\u5230\u7684\u56fe\u7247\u6570\u636e\u53ef\u4ee5\u901a\u8fc7Pillow\u5e93\u8fdb\u884c\u591a\u79cd\u5904\u7406\uff0c\u6bd4\u5982\u8c03\u6574\u5927\u5c0f\u3001\u65cb\u8f6c\u6216\u5e94\u7528\u6ee4\u955c\u3002\u4f7f\u7528<code>Image<\/code>\u5bf9\u8c61\uff0c\u60a8\u53ef\u4ee5\u8c03\u7528\u76f8\u5173\u7684\u65b9\u6cd5\u8fdb\u884c\u64cd\u4f5c\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>resize()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u6539\u53d8\u56fe\u7247\u7684\u5c3a\u5bf8\uff0c\u800c<code>rotate()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u65cb\u8f6c\u56fe\u7247\u3002\u5bf9\u4e8e\u66f4\u590d\u6742\u7684\u64cd\u4f5c\uff0cPillow\u8fd8\u652f\u6301\u56fe\u50cf\u5408\u6210\u548c\u589e\u5f3a\u529f\u80fd\u3002<\/p>\n<p><strong>\u5728\u8bfb\u53d6\u5927\u91cf\u56fe\u7247\u65f6\uff0c\u5982\u4f55\u63d0\u9ad8\u6548\u7387\uff1f<\/strong><br \/>\u5f53\u9700\u8981\u8bfb\u53d6\u5927\u91cf\u56fe\u7247\u65f6\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u591a\u7ebf\u7a0b\u6216\u591a\u8fdb\u7a0b\u6280\u672f\u6765\u63d0\u9ad8\u6548\u7387\u3002Python\u7684<code>concurrent.futures<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u7b80\u5355\u7684\u63a5\u53e3\uff0c\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u5e76\u53d1\u8bfb\u53d6\u3002\u540c\u65f6\uff0c\u60a8\u4e5f\u53ef\u4ee5\u901a\u8fc7\u6279\u91cf\u5904\u7406\u7684\u65b9\u5f0f\uff0c\u51cf\u5c11\u5bf9\u6587\u4ef6\u7cfb\u7edf\u7684\u8bbf\u95ee\u6b21\u6570\uff0c\u8fd9\u6837\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8\u8bfb\u53d6\u901f\u5ea6\u3002\u6b64\u5916\uff0c\u8003\u8651\u4f7f\u7528\u751f\u6210\u5668\u9010\u4e2a\u52a0\u8f7d\u56fe\u7247\uff0c\u907f\u514d\u4e00\u6b21\u6027\u52a0\u8f7d\u8fc7\u591a\u56fe\u7247\u5bfc\u81f4\u5185\u5b58\u5360\u7528\u8fc7\u9ad8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8bfb\u53d6\u6587\u4ef6\u5939\u7684\u56fe\u7247\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u591a\u79cd\u4e0d\u540c\u7684\u5e93\u6765\u5b9e\u73b0\uff0c\u5e38\u7528\u7684\u5305\u62ecos\u5e93\u3001glob\u5e93\u548cPillow\u5e93 [&hellip;]","protected":false},"author":3,"featured_media":1134204,"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\/1134196"}],"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=1134196"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1134196\/revisions"}],"predecessor-version":[{"id":1134206,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1134196\/revisions\/1134206"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1134204"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1134196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1134196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1134196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}