{"id":1135780,"date":"2025-01-08T21:28:59","date_gmt":"2025-01-08T13:28:59","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1135780.html"},"modified":"2025-01-08T21:29:02","modified_gmt":"2025-01-08T13:29:02","slug":"python%e5%a6%82%e4%bd%95%e8%be%93%e5%85%a5%e5%90%8c%e6%97%b6%e5%90%ab%e6%9c%89%e6%95%b0%e5%ad%97%e5%92%8c%e5%ad%97%e7%ac%a6%e4%b8%b2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1135780.html","title":{"rendered":"python\u5982\u4f55\u8f93\u5165\u540c\u65f6\u542b\u6709\u6570\u5b57\u548c\u5b57\u7b26\u4e32"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25104337\/8890d681-9dc4-4f29-be2f-9d5293e18603.webp\" alt=\"python\u5982\u4f55\u8f93\u5165\u540c\u65f6\u542b\u6709\u6570\u5b57\u548c\u5b57\u7b26\u4e32\" \/><\/p>\n<p><p> <strong>\u8981\u5728Python\u4e2d\u8f93\u5165\u540c\u65f6\u542b\u6709\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u6bd4\u5982\u901a\u8fc7<code>input()<\/code>\u51fd\u6570\u8bfb\u53d6\u7528\u6237\u8f93\u5165\u3001\u5229\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u8fdb\u884c\u89e3\u6790\u3001\u6216\u8005\u901a\u8fc7\u7279\u5b9a\u7684\u6570\u636e\u7ed3\u6784\u8fdb\u884c\u7ba1\u7406\u3002<\/strong>\u5176\u4e2d\uff0c\u6700\u76f4\u63a5\u548c\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u8bfb\u53d6\u8f93\u5165\u6570\u636e\uff0c\u7136\u540e\u8fdb\u884c\u9002\u5f53\u7684\u5904\u7406\u548c\u8f6c\u6362\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u51e0\u79cd\u5b9e\u73b0\u65b9\u6cd5\uff0c\u5e76\u63a2\u8ba8\u5b83\u4eec\u7684\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u5229\u7528 <code>input()<\/code> \u51fd\u6570\u8bfb\u53d6\u548c\u5904\u7406\u8f93\u5165<\/h2>\n<\/p>\n<p><h3>1.1 \u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p><code>input()<\/code>\u51fd\u6570\u662fPython\u4e2d\u6700\u57fa\u7840\u7684\u7528\u6237\u8f93\u5165\u65b9\u6cd5\u3002\u5b83\u4f1a\u8bfb\u53d6\u4e00\u884c\u8f93\u5165\u5e76\u5c06\u5176\u4f5c\u4e3a\u5b57\u7b26\u4e32\u8fd4\u56de\u3002\u5982\u679c\u9700\u8981\u540c\u65f6\u5904\u7406\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u5148\u8bfb\u53d6\u6574\u4e2a\u8f93\u5165\uff0c\u7136\u540e\u8fdb\u884c\u89e3\u6790\u548c\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a&quot;)<\/p>\n<h2><strong>\u6253\u5370\u8f93\u5165\u5185\u5bb9<\/strong><\/h2>\n<p>print(&quot;\u4f60\u8f93\u5165\u7684\u662f\uff1a&quot;, user_input)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1.2 \u89e3\u6790\u8f93\u5165\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u4ece\u8f93\u5165\u4e2d\u63d0\u53d6\u51fa\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u6216\u6b63\u5219\u8868\u8fbe\u5f0f\u3002\u4ee5\u4e0b\u793a\u4f8b\u5c55\u793a\u4e86\u5982\u4f55\u4f7f\u7528\u5b57\u7b26\u4e32\u65b9\u6cd5\u8fdb\u884c\u89e3\u6790\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a&quot;)<\/p>\n<h2><strong>\u5206\u79bb\u6570\u5b57\u548c\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>numbers = &#39;&#39;.join(filter(str.isdigit, user_input))<\/p>\n<p>strings = &#39;&#39;.join(filter(str.isalpha, user_input))<\/p>\n<p>print(&quot;\u6570\u5b57\u90e8\u5206\uff1a&quot;, numbers)<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a&quot;, strings)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1.3 \u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u89e3\u6790<\/h3>\n<\/p>\n<p><p>\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u4e00\u79cd\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u7cbe\u786e\u5730\u5339\u914d\u548c\u63d0\u53d6\u8f93\u5165\u4e2d\u7684\u7279\u5b9a\u6a21\u5f0f\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<h2><strong>\u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/strong><\/h2>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a&quot;)<\/p>\n<h2><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u6570\u5b57\u548c\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>numbers = re.findall(r&#39;\\d+&#39;, user_input)<\/p>\n<p>strings = re.findall(r&#39;[a-zA-Z]+&#39;, user_input)<\/p>\n<p>print(&quot;\u6570\u5b57\u90e8\u5206\uff1a&quot;, numbers)<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a&quot;, strings)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528 <code>split()<\/code> \u65b9\u6cd5\u8fdb\u884c\u5206\u5272<\/h2>\n<\/p>\n<p><h3>2.1 \u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u8f93\u5165\u683c\u5f0f\u6bd4\u8f83\u89c4\u8303\uff0c\u53ef\u4ee5\u901a\u8fc7<code>split()<\/code>\u65b9\u6cd5\u5c06\u8f93\u5165\u5206\u5272\u6210\u591a\u4e2a\u90e8\u5206\uff0c\u7136\u540e\u8fdb\u884c\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u4ee5\u7a7a\u683c\u5206\u9694\u7684\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff1a&quot;)<\/p>\n<h2><strong>\u5206\u5272\u8f93\u5165\u5185\u5bb9<\/strong><\/h2>\n<p>parts = user_input.split()<\/p>\n<h2><strong>\u5047\u8bbe\u8f93\u5165\u7684\u7b2c\u4e00\u4e2a\u90e8\u5206\u662f\u6570\u5b57\uff0c\u7b2c\u4e8c\u4e2a\u90e8\u5206\u662f\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>numbers = parts[0]<\/p>\n<p>strings = parts[1]<\/p>\n<p>print(&quot;\u6570\u5b57\u90e8\u5206\uff1a&quot;, numbers)<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a&quot;, strings)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2.2 \u5904\u7406\u590d\u6742\u8f93\u5165<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u8f93\u5165\u683c\u5f0f\u6bd4\u8f83\u590d\u6742\uff0c\u53ef\u4ee5\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\u8fdb\u884c\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a&quot;)<\/p>\n<h2><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u5206\u5272\u5e76\u63d0\u53d6\u6570\u5b57\u548c\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>import re<\/p>\n<p>parts = re.findall(r&#39;\\d+|\\D+&#39;, user_input)<\/p>\n<p>numbers = [part for part in parts if part.isdigit()]<\/p>\n<p>strings = [part for part in parts if part.isalpha()]<\/p>\n<p>print(&quot;\u6570\u5b57\u90e8\u5206\uff1a&quot;, numbers)<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a&quot;, strings)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u6570\u636e\u7ed3\u6784\u7ba1\u7406\u8f93\u5165\u5185\u5bb9<\/h2>\n<\/p>\n<p><h3>3.1 \u4f7f\u7528\u5b57\u5178\u5b58\u50a8<\/h3>\n<\/p>\n<p><p>\u53ef\u4ee5\u4f7f\u7528\u5b57\u5178\u6765\u5b58\u50a8\u4e0d\u540c\u7c7b\u578b\u7684\u6570\u636e\uff0c\u4ee5\u4fbf\u540e\u7eed\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\"># \u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/p>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a&quot;)<\/p>\n<h2><strong>\u521d\u59cb\u5316\u5b57\u5178<\/strong><\/h2>\n<p>data = {&quot;numbers&quot;: [], &quot;strings&quot;: []}<\/p>\n<h2><strong>\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u63d0\u53d6\u6570\u5b57\u548c\u5b57\u7b26\u4e32<\/strong><\/h2>\n<p>import re<\/p>\n<p>parts = re.findall(r&#39;\\d+|\\D+&#39;, user_input)<\/p>\n<h2><strong>\u5c06\u6570\u5b57\u548c\u5b57\u7b26\u4e32\u5206\u522b\u5b58\u50a8\u5230\u5b57\u5178\u4e2d<\/strong><\/h2>\n<p>for part in parts:<\/p>\n<p>    if part.isdigit():<\/p>\n<p>        data[&quot;numbers&quot;].append(int(part))<\/p>\n<p>    else:<\/p>\n<p>        data[&quot;strings&quot;].append(part)<\/p>\n<p>print(&quot;\u6570\u5b57\u90e8\u5206\uff1a&quot;, data[&quot;numbers&quot;])<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a&quot;, data[&quot;strings&quot;])<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3.2 \u4f7f\u7528\u7c7b\u8fdb\u884c\u5c01\u88c5<\/h3>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u597d\u5730\u7ba1\u7406\u8f93\u5165\u6570\u636e\uff0c\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u7c7b\u6765\u5c01\u88c5\u5904\u7406\u903b\u8f91\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">class InputParser:<\/p>\n<p>    def __init__(self, user_input):<\/p>\n<p>        self.user_input = user_input<\/p>\n<p>        self.numbers = []<\/p>\n<p>        self.strings = []<\/p>\n<p>        self.parse_input()<\/p>\n<p>    def parse_input(self):<\/p>\n<p>        import re<\/p>\n<p>        parts = re.findall(r&#39;\\d+|\\D+&#39;, self.user_input)<\/p>\n<p>        for part in parts:<\/p>\n<p>            if part.isdigit():<\/p>\n<p>                self.numbers.append(int(part))<\/p>\n<p>            else:<\/p>\n<p>                self.strings.append(part)<\/p>\n<p>    def get_numbers(self):<\/p>\n<p>        return self.numbers<\/p>\n<p>    def get_strings(self):<\/p>\n<p>        return self.strings<\/p>\n<h2><strong>\u8bfb\u53d6\u7528\u6237\u8f93\u5165<\/strong><\/h2>\n<p>user_input = input(&quot;\u8bf7\u8f93\u5165\u5185\u5bb9\uff1a&quot;)<\/p>\n<h2><strong>\u521b\u5efaInputParser\u5bf9\u8c61\u5e76\u89e3\u6790\u8f93\u5165<\/strong><\/h2>\n<p>parser = InputParser(user_input)<\/p>\n<p>print(&quot;\u6570\u5b57\u90e8\u5206\uff1a&quot;, parser.get_numbers())<\/p>\n<p>print(&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a&quot;, parser.get_strings())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u603b\u7ed3<\/h2>\n<\/p>\n<p><p>\u5728Python\u4e2d\u5904\u7406\u540c\u65f6\u5305\u542b\u6570\u5b57\u548c\u5b57\u7b26\u4e32\u7684\u8f93\u5165\u6709\u591a\u79cd\u65b9\u6cd5\uff0c\u5305\u62ec\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u6570\u636e\u7ed3\u6784\u548c\u7c7b\u5c01\u88c5\u7b49\u3002\u6bcf\u79cd\u65b9\u6cd5\u90fd\u6709\u5176\u4f18\u7f3a\u70b9\u548c\u9002\u7528\u573a\u666f\u3002<strong>\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u53ef\u4ee5\u5feb\u901f\u83b7\u53d6\u7528\u6237\u8f93\u5165\u3001\u5b57\u7b26\u4e32\u65b9\u6cd5\u9002\u5408\u7b80\u5355\u89e3\u6790\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u9002\u5408\u590d\u6742\u5339\u914d\u3001\u6570\u636e\u7ed3\u6784\u548c\u7c7b\u5c01\u88c5\u5219\u9002\u7528\u4e8e\u9700\u8981\u7ba1\u7406\u548c\u5904\u7406\u5927\u91cf\u6570\u636e\u7684\u573a\u666f\u3002<\/strong>\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u7ef4\u62a4\u6027\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u540c\u65f6\u8f93\u5165\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528<code>input()<\/code>\u51fd\u6570\u6765\u83b7\u53d6\u7528\u6237\u8f93\u5165\uff0c\u8f93\u5165\u7684\u5185\u5bb9\u9ed8\u8ba4\u4f1a\u88ab\u89c6\u4e3a\u5b57\u7b26\u4e32\u3002\u5982\u679c\u9700\u8981\u540c\u65f6\u5904\u7406\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u5728\u63a5\u6536\u5230\u8f93\u5165\u540e\u8fdb\u884c\u7c7b\u578b\u8f6c\u6362\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528<code>int()<\/code>\u6216<code>float()<\/code>\u51fd\u6570\u5c06\u6570\u5b57\u90e8\u5206\u8f6c\u6362\u4e3a\u6570\u503c\u7c7b\u578b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff1a  <\/p>\n<pre><code class=\"language-python\">user_input = input(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\u548c\u4e00\u4e2a\u6570\u5b57\uff0c\u7528\u7a7a\u683c\u5206\u9694\uff1a&quot;)\nstring_part, number_part = user_input.split()\nnumber_part = float(number_part)  # \u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\nprint(f&quot;\u5b57\u7b26\u4e32\u90e8\u5206\uff1a{string_part}, \u6570\u5b57\u90e8\u5206\uff1a{number_part}&quot;)\n<\/code><\/pre>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5904\u7406\u6df7\u5408\u6570\u636e\u7c7b\u578b\u7684\u8f93\u5165\uff1f<\/strong><br \/>\u5904\u7406\u6df7\u5408\u6570\u636e\u7c7b\u578b\u7684\u8f93\u5165\u65f6\uff0c\u53ef\u4ee5\u5229\u7528<code>input()<\/code>\u51fd\u6570\u63a5\u6536\u7528\u6237\u8f93\u5165\uff0c\u5e76\u901a\u8fc7\u5b57\u7b26\u4e32\u64cd\u4f5c\u5c06\u6570\u636e\u5206\u79bb\u3002\u4f7f\u7528<code>split()<\/code>\u65b9\u6cd5\u53ef\u5e2e\u52a9\u5c06\u8f93\u5165\u7684\u5b57\u7b26\u4e32\u6309\u7a7a\u683c\u5206\u5272\u6210\u591a\u4e2a\u90e8\u5206\u3002\u4e3a\u4e86\u786e\u4fdd\u8f93\u5165\u7684\u6570\u5b57\u90e8\u5206\u80fd\u591f\u6b63\u786e\u8f6c\u5316\u4e3a\u6570\u5b57\u7c7b\u578b\uff0c\u53ef\u4ee5\u4f7f\u7528\u5f02\u5e38\u5904\u7406\u6765\u6355\u83b7\u53ef\u80fd\u7684\u9519\u8bef\u3002\u4ee5\u4e0b\u662f\u5904\u7406\u8f93\u5165\u7684\u793a\u4f8b\uff1a  <\/p>\n<pre><code class=\"language-python\">user_input = input(&quot;\u8bf7\u8f93\u5165\u5b57\u7b26\u4e32\u548c\u6570\u5b57\uff1a&quot;)\ntry:\n    string_part, number_part = user_input.split()\n    number_part = int(number_part)  # \u53ef\u4ee5\u6839\u636e\u9700\u8981\u8f6c\u6362\u6210\u5176\u4ed6\u6570\u503c\u7c7b\u578b\nexcept ValueError:\n    print(&quot;\u8f93\u5165\u683c\u5f0f\u9519\u8bef\uff0c\u8bf7\u786e\u4fdd\u8f93\u5165\u5305\u542b\u4e00\u4e2a\u5b57\u7b26\u4e32\u548c\u4e00\u4e2a\u6570\u5b57\u3002&quot;)\n<\/code><\/pre>\n<p><strong>\u6709\u54ea\u4e9b\u65b9\u6cd5\u53ef\u4ee5\u9a8c\u8bc1\u7528\u6237\u8f93\u5165\u7684\u683c\u5f0f\uff1f<\/strong><br \/>\u5728\u5904\u7406\u7528\u6237\u8f93\u5165\u65f6\uff0c\u9a8c\u8bc1\u683c\u5f0f\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u68c0\u67e5\u8f93\u5165\u662f\u5426\u7b26\u5408\u9884\u671f\u683c\u5f0f\u3002\u901a\u8fc7<code>re<\/code>\u6a21\u5757\uff0c\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u6a21\u5f0f\u6765\u5339\u914d\u540c\u65f6\u5305\u542b\u6570\u5b57\u548c\u5b57\u7b26\u4e32\u7684\u8f93\u5165\u3002\u4f8b\u5982\uff1a  <\/p>\n<pre><code class=\"language-python\">import re\n\nuser_input = input(&quot;\u8bf7\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\u548c\u4e00\u4e2a\u6570\u5b57\uff1a&quot;)\npattern = r&#39;^[a-zA-Z]+ \\d+$&#39;  # \u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u786e\u4fdd\u5b57\u7b26\u4e32\u548c\u6570\u5b57\u95f4\u6709\u7a7a\u683c\nif re.match(pattern, user_input):\n    string_part, number_part = user_input.split()\n    print(f&quot;\u8f93\u5165\u6709\u6548\uff0c\u5b57\u7b26\u4e32\u90e8\u5206\uff1a{string_part}, \u6570\u5b57\u90e8\u5206\uff1a{number_part}&quot;)\nelse:\n    print(&quot;\u8f93\u5165\u683c\u5f0f\u4e0d\u6b63\u786e\uff0c\u8bf7\u8f93\u5165\u4e00\u4e2a\u5b57\u7b26\u4e32\u548c\u4e00\u4e2a\u6570\u5b57\u3002&quot;)\n<\/code><\/pre>\n<p>\u4f7f\u7528\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u6709\u6548\u63d0\u9ad8\u8f93\u5165\u7684\u53ef\u9760\u6027\u548c\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Python\u4e2d\u8f93\u5165\u540c\u65f6\u542b\u6709\u6570\u5b57\u548c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528\u591a\u79cd\u65b9\u6cd5\uff0c\u6bd4\u5982\u901a\u8fc7input()\u51fd\u6570\u8bfb\u53d6\u7528\u6237\u8f93\u5165\u3001\u5229\u7528\u6b63\u5219 [&hellip;]","protected":false},"author":3,"featured_media":1135787,"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\/1135780"}],"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=1135780"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1135780\/revisions"}],"predecessor-version":[{"id":1135788,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1135780\/revisions\/1135788"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1135787"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1135780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1135780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1135780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}