{"id":1078420,"date":"2025-01-08T12:11:25","date_gmt":"2025-01-08T04:11:25","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1078420.html"},"modified":"2025-01-08T12:11:28","modified_gmt":"2025-01-08T04:11:28","slug":"python%e8%bf%90%e8%a1%8c%e8%bf%87%e7%a8%8b%e4%b8%ad%e5%a6%82%e4%bd%95%e7%9c%8b%e8%bf%9b%e5%ba%a6-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1078420.html","title":{"rendered":"python\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u5982\u4f55\u770b\u8fdb\u5ea6"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24182000\/234c23a7-207d-4c87-97c6-ded31e7cd83b.webp\" alt=\"python\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u5982\u4f55\u770b\u8fdb\u5ea6\" \/><\/p>\n<p><p> <strong>\u5728Python\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u67e5\u770b\u8fdb\u5ea6\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff1a\u4f7f\u7528print\u51fd\u6570\u3001\u4f7f\u7528tqdm\u5e93\u3001\u4f7f\u7528logging\u5e93\u3001\u4f7f\u7528\u8fdb\u5ea6\u6761\u3001\u4f7f\u7528\u56de\u8c03\u51fd\u6570\u3001\u4f7f\u7528\u7ebf\u7a0b\u3002\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528tqdm\u5e93\uff0c\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u5c01\u88c5\uff0c\u53ef\u4ee5\u5728\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u5faa\u73af\u4e2d\u5b9e\u73b0\u8fdb\u5ea6\u6761\u663e\u793a\u3002<\/strong>\u4f7f\u7528tqdm\u5e93\u4e0d\u4ec5\u7b80\u5355\uff0c\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u914d\u7f6e\u9009\u9879\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5927\u90e8\u5206\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528print\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u4f7f\u7528<code>print<\/code>\u51fd\u6570\u6765\u8f93\u51fa\u8fdb\u5ea6\u4fe1\u606f\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u8f83\u4e3a\u7b80\u5355\u7684\u811a\u672c\uff0c\u6216\u8005\u4e0d\u9700\u8981\u7cbe\u786e\u63a7\u5236\u8fdb\u5ea6\u663e\u793a\u7684\u60c5\u51b5\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u5faa\u73af\u4e2d\u63d2\u5165<code>print<\/code>\u8bed\u53e5\u6765\u8f93\u51fa\u5f53\u524d\u8fdb\u5ea6\uff0c\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>total = 100<\/p>\n<p>for i in range(total):<\/p>\n<p>    time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p>    print(f&quot;Progress: {i + 1}\/{total}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u867d\u7136\u7b80\u5355\uff0c\u4f46\u4f1a\u5bfc\u81f4\u8f93\u51fa\u4fe1\u606f\u8fc7\u4e8e\u9891\u7e41\uff0c\u5f71\u54cd\u7a0b\u5e8f\u7684\u6027\u80fd\u548c\u53ef\u8bfb\u6027\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528tqdm\u5e93<\/h2>\n<\/p>\n<p><p><code>tqdm<\/code>\u662f\u4e00\u4e2a\u975e\u5e38\u6d41\u884c\u7684Python\u5e93\uff0c\u7528\u4e8e\u663e\u793a\u8fdb\u5ea6\u6761\u3002\u5b83\u4e0d\u4ec5\u7b80\u5355\u6613\u7528\uff0c\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u914d\u7f6e\u9009\u9879\uff0c\u53ef\u4ee5\u6ee1\u8db3\u5927\u90e8\u5206\u7684\u9700\u6c42\u3002\u4f7f\u7528<code>tqdm<\/code>\u5e93\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5728\u5faa\u73af\u5916\u90e8\u5305\u88f9\u4e00\u5c42<code>tqdm<\/code>\u5373\u53ef\u5b9e\u73b0\u8fdb\u5ea6\u6761\u663e\u793a\u3002<\/p>\n<\/p>\n<p><h3>1. \u5b89\u88c5tqdm<\/h3>\n<\/p>\n<p><p>\u9996\u5148\u9700\u8981\u5b89\u88c5<code>tqdm<\/code>\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install tqdm<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528tqdm\u663e\u793a\u8fdb\u5ea6\u6761<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528<code>tqdm<\/code>\u6765\u663e\u793a\u8fdb\u5ea6\u6761\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from tqdm import tqdm<\/p>\n<p>import time<\/p>\n<p>total = 100<\/p>\n<p>for i in tqdm(range(total)):<\/p>\n<p>    time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>tqdm<\/code>\u4f1a\u81ea\u52a8\u8ba1\u7b97\u5e76\u663e\u793a\u8fdb\u5ea6\u767e\u5206\u6bd4\u3001\u5df2\u5904\u7406\u9879\u6570\u3001\u6bcf\u79d2\u5904\u7406\u9879\u6570\u3001\u9884\u8ba1\u5269\u4f59\u65f6\u95f4\u7b49\u4fe1\u606f\uff0c\u6781\u5927\u5730\u65b9\u4fbf\u4e86\u8fdb\u5ea6\u76d1\u63a7\u3002<\/p>\n<\/p>\n<p><h3>3. \u81ea\u5b9a\u4e49\u8fdb\u5ea6\u6761<\/h3>\n<\/p>\n<p><p><code>tqdm<\/code>\u5e93\u8fd8\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u914d\u7f6e\u9009\u9879\uff0c\u53ef\u4ee5\u81ea\u5b9a\u4e49\u8fdb\u5ea6\u6761\u7684\u663e\u793a\u6837\u5f0f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from tqdm import tqdm<\/p>\n<p>import time<\/p>\n<p>total = 100<\/p>\n<p>with tqdm(total=total, desc=&quot;Processing&quot;, ncols=100, bar_format=&quot;{l_bar}{bar}| {n_fmt}\/{total_fmt} {elapsed}&lt;{rem<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>ning}&quot;) as pbar:<\/p>\n<p>    for i in range(total):<\/p>\n<p>        time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p>        pbar.update(1)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u81ea\u5b9a\u4e49\u4e86\u8fdb\u5ea6\u6761\u7684\u63cf\u8ff0\u3001\u5bbd\u5ea6\u548c\u683c\u5f0f\uff0c\u4f7f\u5176\u66f4\u7b26\u5408\u6211\u4eec\u7684\u9700\u6c42\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528logging\u5e93<\/h2>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u9700\u8981\u8bb0\u5f55\u65e5\u5fd7\u7684\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>logging<\/code>\u5e93\u6765\u8f93\u51fa\u8fdb\u5ea6\u4fe1\u606f\u3002\u4e0e<code>print<\/code>\u51fd\u6570\u4e0d\u540c\uff0c<code>logging<\/code>\u5e93\u53ef\u4ee5\u5c06\u65e5\u5fd7\u4fe1\u606f\u8f93\u51fa\u5230\u63a7\u5236\u53f0\u3001\u6587\u4ef6\u7b49\u591a\u4e2a\u4f4d\u7f6e\uff0c\u5e76\u4e14\u652f\u6301\u4e0d\u540c\u7684\u65e5\u5fd7\u7ea7\u522b\u3002<\/p>\n<\/p>\n<p><h3>1. \u914d\u7f6elogging<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6e<code>logging<\/code>\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>logging.basicConfig(level=logging.INFO, format=&quot;%(asctime)s - %(levelname)s - %(message)s&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528logging\u8f93\u51fa\u8fdb\u5ea6\u4fe1\u606f<\/h3>\n<\/p>\n<p><p>\u914d\u7f6e\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528<code>logging<\/code>\u6765\u8f93\u51fa\u8fdb\u5ea6\u4fe1\u606f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import logging<\/p>\n<p>import time<\/p>\n<p>logging.basicConfig(level=logging.INFO, format=&quot;%(asctime)s - %(levelname)s - %(message)s&quot;)<\/p>\n<p>total = 100<\/p>\n<p>for i in range(total):<\/p>\n<p>    time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p>    logging.info(f&quot;Progress: {i + 1}\/{total}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u53ef\u4ee5\u8f93\u51fa\u8fdb\u5ea6\u4fe1\u606f\uff0c\u8fd8\u53ef\u4ee5\u8bb0\u5f55\u5176\u4ed6\u91cd\u8981\u7684\u65e5\u5fd7\u4fe1\u606f\uff0c\u4fbf\u4e8e\u8c03\u8bd5\u548c\u7ef4\u62a4\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528\u8fdb\u5ea6\u6761<\/h2>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u9700\u8981\u66f4\u590d\u6742\u8fdb\u5ea6\u663e\u793a\u7684\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7b2c\u4e09\u65b9\u7684\u8fdb\u5ea6\u6761\u5e93\uff0c\u4f8b\u5982<code>progressbar2<\/code>\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u66f4\u52a0\u4e30\u5bcc\u548c\u7075\u6d3b\u7684\u8fdb\u5ea6\u663e\u793a\u6548\u679c\u3002<\/p>\n<\/p>\n<p><h3>1. \u5b89\u88c5progressbar2<\/h3>\n<\/p>\n<p><p>\u9996\u5148\u9700\u8981\u5b89\u88c5<code>progressbar2<\/code>\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528pip\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install progressbar2<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528progressbar2\u663e\u793a\u8fdb\u5ea6\u6761<\/h3>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u4f7f\u7528<code>progressbar2<\/code>\u6765\u663e\u793a\u8fdb\u5ea6\u6761\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import progressbar<\/p>\n<p>import time<\/p>\n<p>total = 100<\/p>\n<p>bar = progressbar.ProgressBar(maxval=total, widgets=[progressbar.Bar(&#39;=&#39;, &#39;[&#39;, &#39;]&#39;), &#39; &#39;, progressbar.Percentage()])<\/p>\n<p>bar.start()<\/p>\n<p>for i in range(total):<\/p>\n<p>    time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p>    bar.update(i + 1)<\/p>\n<p>bar.finish()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u66f4\u52a0\u4e30\u5bcc\u548c\u7075\u6d3b\u7684\u8fdb\u5ea6\u663e\u793a\u6548\u679c\uff0c\u4f46\u9700\u8981\u989d\u5916\u5b89\u88c5\u548c\u914d\u7f6e\u7b2c\u4e09\u65b9\u5e93\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u4f7f\u7528\u56de\u8c03\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u9700\u8981\u7cbe\u786e\u63a7\u5236\u8fdb\u5ea6\u663e\u793a\u7684\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u56de\u8c03\u51fd\u6570\u6765\u5b9e\u73b0\u8fdb\u5ea6\u663e\u793a\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u5728\u7279\u5b9a\u65f6\u673a\u66f4\u65b0\u8fdb\u5ea6\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>1. \u5b9a\u4e49\u56de\u8c03\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u56de\u8c03\u51fd\u6570\uff0c\u7528\u4e8e\u66f4\u65b0\u8fdb\u5ea6\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def progress_callback(current, total):<\/p>\n<p>    print(f&quot;Progress: {current}\/{total}&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528\u56de\u8c03\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u8c03\u7528\u56de\u8c03\u51fd\u6570\u6765\u66f4\u65b0\u8fdb\u5ea6\u4fe1\u606f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>def progress_callback(current, total):<\/p>\n<p>    print(f&quot;Progress: {current}\/{total}&quot;)<\/p>\n<p>total = 100<\/p>\n<p>for i in range(total):<\/p>\n<p>    time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p>    progress_callback(i + 1, total)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u867d\u7136\u9700\u8981\u989d\u5916\u5b9a\u4e49\u56de\u8c03\u51fd\u6570\uff0c\u4f46\u53ef\u4ee5\u5b9e\u73b0\u66f4\u52a0\u7075\u6d3b\u548c\u7cbe\u786e\u7684\u8fdb\u5ea6\u63a7\u5236\u3002<\/p>\n<\/p>\n<p><h2>\u516d\u3001\u4f7f\u7528\u7ebf\u7a0b<\/h2>\n<\/p>\n<p><p>\u5728\u4e00\u4e9b\u9700\u8981\u5f02\u6b65\u66f4\u65b0\u8fdb\u5ea6\u7684\u573a\u666f\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u7ebf\u7a0b\u6765\u5b9e\u73b0\u8fdb\u5ea6\u663e\u793a\u3002\u8fd9\u79cd\u65b9\u6cd5\u9002\u7528\u4e8e\u9700\u8981\u5728\u540e\u53f0\u66f4\u65b0\u8fdb\u5ea6\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>1. \u5b9a\u4e49\u8fdb\u5ea6\u7ebf\u7a0b<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u6211\u4eec\u9700\u8981\u5b9a\u4e49\u4e00\u4e2a\u8fdb\u5ea6\u7ebf\u7a0b\uff0c\u7528\u4e8e\u5f02\u6b65\u66f4\u65b0\u8fdb\u5ea6\u4fe1\u606f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>import time<\/p>\n<p>class ProgressThread(threading.Thread):<\/p>\n<p>    def __init__(self, total):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.total = total<\/p>\n<p>        self.current = 0<\/p>\n<p>    def run(self):<\/p>\n<p>        while self.current &lt; self.total:<\/p>\n<p>            print(f&quot;Progress: {self.current}\/{self.total}&quot;)<\/p>\n<p>            time.sleep(1)<\/p>\n<p>    def update(self, value):<\/p>\n<p>        self.current = value<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2. \u4f7f\u7528\u8fdb\u5ea6\u7ebf\u7a0b<\/h3>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u542f\u52a8\u8fdb\u5ea6\u7ebf\u7a0b\uff0c\u5e76\u5728\u4e3b\u7ebf\u7a0b\u4e2d\u66f4\u65b0\u8fdb\u5ea6\u4fe1\u606f\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import time<\/p>\n<p>class ProgressThread(threading.Thread):<\/p>\n<p>    def __init__(self, total):<\/p>\n<p>        super().__init__()<\/p>\n<p>        self.total = total<\/p>\n<p>        self.current = 0<\/p>\n<p>    def run(self):<\/p>\n<p>        while self.current &lt; self.total:<\/p>\n<p>            print(f&quot;Progress: {self.current}\/{self.total}&quot;)<\/p>\n<p>            time.sleep(1)<\/p>\n<p>    def update(self, value):<\/p>\n<p>        self.current = value<\/p>\n<p>total = 100<\/p>\n<p>progress_thread = ProgressThread(total)<\/p>\n<p>progress_thread.start()<\/p>\n<p>for i in range(total):<\/p>\n<p>    time.sleep(0.1)  # \u6a21\u62df\u8017\u65f6\u64cd\u4f5c<\/p>\n<p>    progress_thread.update(i + 1)<\/p>\n<p>progress_thread.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u867d\u7136\u9700\u8981\u989d\u5916\u5b9a\u4e49\u548c\u7ba1\u7406\u8fdb\u5ea6\u7ebf\u7a0b\uff0c\u4f46\u53ef\u4ee5\u5b9e\u73b0\u66f4\u52a0\u7075\u6d3b\u548c\u5f02\u6b65\u7684\u8fdb\u5ea6\u63a7\u5236\u3002<\/p>\n<\/p>\n<p><h2>\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u5728Python\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u67e5\u770b\u8fdb\u5ea6\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff1a\u4f7f\u7528<code>print<\/code>\u51fd\u6570\u3001\u4f7f\u7528<code>tqdm<\/code>\u5e93\u3001\u4f7f\u7528<code>logging<\/code>\u5e93\u3001\u4f7f\u7528\u8fdb\u5ea6\u6761\u3001\u4f7f\u7528\u56de\u8c03\u51fd\u6570\u3001\u4f7f\u7528\u7ebf\u7a0b\u3002\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>tqdm<\/code>\u5e93\uff0c\u901a\u8fc7\u4e00\u4e2a\u7b80\u5355\u7684\u5c01\u88c5\uff0c\u53ef\u4ee5\u5728\u957f\u65f6\u95f4\u8fd0\u884c\u7684\u5faa\u73af\u4e2d\u5b9e\u73b0\u8fdb\u5ea6\u6761\u663e\u793a\u3002\u6839\u636e\u4e0d\u540c\u7684\u9700\u6c42\u548c\u573a\u666f\uff0c\u6211\u4eec\u53ef\u4ee5\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u6765\u5b9e\u73b0\u8fdb\u5ea6\u663e\u793a\uff0c\u4ee5\u63d0\u9ad8\u7a0b\u5e8f\u7684\u53ef\u8bfb\u6027\u548c\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u7a0b\u5e8f\u4e2d\u5b9e\u65f6\u76d1\u63a7\u8fdb\u5ea6\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6709\u591a\u79cd\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u65f6\u76d1\u63a7\u7a0b\u5e8f\u7684\u8fd0\u884c\u8fdb\u5ea6\u3002\u5e38\u89c1\u7684\u65b9\u5f0f\u5305\u62ec\u4f7f\u7528<code>tqdm<\/code>\u5e93\uff0c\u5b83\u53ef\u4ee5\u8f7b\u677e\u5730\u4e3a\u5faa\u73af\u6dfb\u52a0\u8fdb\u5ea6\u6761\u3002\u53ea\u9700\u5728\u4f60\u7684\u5faa\u73af\u4e2d\u5305\u88c5\u4e00\u4e2a\u53ef\u8fed\u4ee3\u5bf9\u8c61\uff0c\u5c31\u53ef\u4ee5\u770b\u5230\u8fdb\u5ea6\u6761\u7684\u5b9e\u65f6\u66f4\u65b0\u3002\u6b64\u5916\uff0c\u4f7f\u7528<code>logging<\/code>\u6a21\u5757\u8bb0\u5f55\u8fdb\u5ea6\u4fe1\u606f\u4e5f\u80fd\u5e2e\u52a9\u8ddf\u8e2a\u7a0b\u5e8f\u7684\u6267\u884c\u72b6\u6001\u3002<\/p>\n<p><strong>Python\u6709\u54ea\u4e9b\u5de5\u5177\u53ef\u4ee5\u7528\u4e8e\u663e\u793a\u8fdb\u5ea6\u6761\uff1f<\/strong><br \/>\u9664\u4e86<code>tqdm<\/code>\uff0c\u8fd8\u6709\u5176\u4ed6\u5de5\u5177\u53ef\u4ee5\u7528\u6765\u663e\u793a\u8fdb\u5ea6\u6761\u3002\u4f8b\u5982\uff0c<code>progressbar<\/code>\u548c<code>alive-progress<\/code>\u5e93\u4e5f\u975e\u5e38\u53d7\u6b22\u8fce\u3002\u6bcf\u4e2a\u5e93\u90fd\u6709\u5176\u72ec\u7279\u7684\u529f\u80fd\u548c\u4f7f\u7528\u65b9\u5f0f\uff0c\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u548c\u4e2a\u4eba\u559c\u597d\u6765\u51b3\u5b9a\u3002<\/p>\n<p><strong>\u5982\u4f55\u81ea\u5b9a\u4e49\u8fdb\u5ea6\u6761\u7684\u6837\u5f0f\u548c\u4fe1\u606f\uff1f<\/strong><br \/>\u5982\u679c\u9700\u8981\u81ea\u5b9a\u4e49\u8fdb\u5ea6\u6761\u7684\u6837\u5f0f\uff0c\u53ef\u4ee5\u4f7f\u7528<code>tqdm<\/code>\u5e93\u4e2d\u7684\u53c2\u6570\u6765\u8c03\u6574\u3002\u6bd4\u5982\uff0c\u53ef\u4ee5\u8bbe\u7f6e\u8fdb\u5ea6\u6761\u7684\u5bbd\u5ea6\u3001\u524d\u7f00\u4fe1\u606f\u3001\u540e\u7f00\u4fe1\u606f\u7b49\u3002\u901a\u8fc7\u8c03\u6574\u8fd9\u4e9b\u53c2\u6570\uff0c\u53ef\u4ee5\u4f7f\u8fdb\u5ea6\u6761\u66f4\u7b26\u5408\u4f60\u7684\u9879\u76ee\u9700\u6c42\uff0c\u4ece\u800c\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u8fd0\u884c\u8fc7\u7a0b\u4e2d\u67e5\u770b\u8fdb\u5ea6\u7684\u65b9\u6cd5\u6709\u5f88\u591a\uff1a\u4f7f\u7528print\u51fd\u6570\u3001\u4f7f\u7528tqdm\u5e93\u3001\u4f7f\u7528logging\u5e93\u3001\u4f7f\u7528\u8fdb [&hellip;]","protected":false},"author":3,"featured_media":1078427,"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\/1078420"}],"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=1078420"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1078420\/revisions"}],"predecessor-version":[{"id":1078429,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1078420\/revisions\/1078429"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1078427"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1078420"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1078420"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1078420"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}