{"id":1138101,"date":"2025-01-08T21:56:01","date_gmt":"2025-01-08T13:56:01","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1138101.html"},"modified":"2025-01-08T21:56:04","modified_gmt":"2025-01-08T13:56:04","slug":"python%e5%a6%82%e4%bd%95%e5%b0%86%e5%ad%97%e7%ac%a6%e4%b8%b2%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2%e4%b8%ba%e6%95%b4%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1138101.html","title":{"rendered":"python\u5982\u4f55\u5c06\u5b57\u7b26\u4e32\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u578b"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25101806\/fa42334d-7836-465d-b991-2aa3bcca19c8.webp\" alt=\"python\u5982\u4f55\u5c06\u5b57\u7b26\u4e32\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u578b\" \/><\/p>\n<p><p> <strong>\u5c06\u5b57\u7b26\u4e32\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u578b\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5982\u4f7f\u7528<code>int()<\/code>\u51fd\u6570\u3001\u5904\u7406\u53ef\u80fd\u7684\u5f02\u5e38\u3001\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u7b49\u3002<\/strong>\u5176\u4e2d\uff0c\u6700\u5e38\u7528\u7684\u65b9\u6cd5\u662f\u4f7f\u7528\u5185\u7f6e\u7684<code>int()<\/code>\u51fd\u6570\uff0c\u8fd9\u4e2a\u65b9\u6cd5\u7b80\u5355\u6613\u61c2\u4e14\u9ad8\u6548\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\uff0c\u5e76\u63a2\u8ba8\u5176\u4ed6\u76f8\u5173\u65b9\u6cd5\u548c\u6ce8\u610f\u4e8b\u9879\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e00\u3001\u4f7f\u7528int()\u51fd\u6570<\/h2>\n<\/p>\n<p><p><code>int()<\/code>\u51fd\u6570\u662fPython\u5185\u7f6e\u7684\u7c7b\u578b\u8f6c\u6362\u51fd\u6570\uff0c\u80fd\u591f\u5c06\u5b57\u7b26\u4e32\u8f6c\u5316\u4e3a\u6574\u578b\u3002\u5176\u57fa\u672c\u7528\u6cd5\u5982\u4e0b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number_str = &quot;123&quot;<\/p>\n<p>number_int = int(number_str)<\/p>\n<p>print(number_int)  # \u8f93\u51fa: 123<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u793a\u4f8b\u4e2d\uff0c<code>int()<\/code>\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u5b57\u7b26\u4e32\u53c2\u6570\uff0c\u5e76\u5c06\u5176\u8f6c\u6362\u4e3a\u6574\u578b\u3002\u5982\u679c\u5b57\u7b26\u4e32\u662f\u4e00\u4e2a\u6709\u6548\u7684\u6570\u5b57\u8868\u793a\uff0c\u6bd4\u5982&quot;123&quot;\uff0c\u8f6c\u6362\u5c06\u4f1a\u6210\u529f\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5904\u7406\u5f02\u5e38<\/h3>\n<\/p>\n<p><p>\u5e76\u4e0d\u662f\u6240\u6709\u7684\u5b57\u7b26\u4e32\u90fd\u53ef\u4ee5\u987a\u5229\u8f6c\u6362\u4e3a\u6574\u578b\u3002\u4f8b\u5982\uff0c\u5305\u542b\u5b57\u6bcd\u6216\u7279\u6b8a\u5b57\u7b26\u7684\u5b57\u7b26\u4e32\u5c06\u4f1a\u5bfc\u81f4\u8f6c\u6362\u5931\u8d25\uff0c\u629b\u51fa<code>ValueError<\/code>\u5f02\u5e38\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number_str = &quot;123abc&quot;<\/p>\n<p>try:<\/p>\n<p>    number_int = int(number_str)<\/p>\n<p>except ValueError:<\/p>\n<p>    print(&quot;\u8f6c\u6362\u5931\u8d25\uff0c\u5b57\u7b26\u4e32\u5305\u542b\u975e\u6570\u5b57\u5b57\u7b26&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u4f18\u96c5\u5730\u5904\u7406\u8f6c\u6362\u5931\u8d25\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26<\/h3>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u5b57\u7b26\u4e32\u4e2d\u53ef\u80fd\u5305\u542b\u4e00\u4e9b\u4e0d\u5fc5\u8981\u7684\u7279\u6b8a\u5b57\u7b26\uff08\u5982\u7a7a\u683c\u3001\u9017\u53f7\u7b49\uff09\u3002\u6211\u4eec\u53ef\u4ee5\u5728\u8f6c\u6362\u524d\u4f7f\u7528\u5b57\u7b26\u4e32\u5904\u7406\u65b9\u6cd5\u6765\u53bb\u9664\u8fd9\u4e9b\u7279\u6b8a\u5b57\u7b26\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number_str = &quot; 1,234 &quot;<\/p>\n<p>cleaned_str = number_str.replace(&quot;,&quot;, &quot;&quot;).strip()<\/p>\n<p>number_int = int(cleaned_str)<\/p>\n<p>print(number_int)  # \u8f93\u51fa: 1234<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86<code>replace()<\/code>\u65b9\u6cd5\u53bb\u9664\u9017\u53f7\uff0c<code>strip()<\/code>\u65b9\u6cd5\u53bb\u9664\u524d\u540e\u7684\u7a7a\u683c\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e8c\u3001\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f<\/h2>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u590d\u6742\u60c5\u51b5\u4e0b\uff0c\u5b57\u7b26\u4e32\u53ef\u80fd\u5305\u542b\u591a\u79cd\u5f62\u5f0f\u7684\u975e\u6570\u5b57\u5b57\u7b26\uff0c\u8fd9\u65f6\u53ef\u4ee5\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u6765\u63d0\u53d6\u5176\u4e2d\u7684\u6570\u5b57\u90e8\u5206\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u7528\u6cd5<\/h3>\n<\/p>\n<p><p>Python\u7684<code>re<\/code>\u6a21\u5757\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u529f\u80fd\uff0c\u53ef\u4ee5\u7528\u6765\u5339\u914d\u548c\u63d0\u53d6\u5b57\u7b26\u4e32\u4e2d\u7684\u6570\u5b57\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import re<\/p>\n<p>number_str = &quot;Total: 12345 items&quot;<\/p>\n<p>matches = re.findall(r&#39;\\d+&#39;, number_str)<\/p>\n<p>if matches:<\/p>\n<p>    number_int = int(matches[0])<\/p>\n<p>    print(number_int)  # \u8f93\u51fa: 12345<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5904\u7406\u591a\u4e2a\u5339\u914d\u7ed3\u679c<\/h3>\n<\/p>\n<p><p>\u5982\u679c\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u591a\u4e2a\u6570\u5b57\uff0c\u53ef\u4ee5\u9009\u62e9\u53ea\u63d0\u53d6\u7b2c\u4e00\u4e2a\u6216\u8fdb\u884c\u67d0\u79cd\u5408\u5e76\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number_str = &quot;Numbers: 12, 34 and 56&quot;<\/p>\n<p>matches = re.findall(r&#39;\\d+&#39;, number_str)<\/p>\n<p>if matches:<\/p>\n<p>    numbers = [int(match) for match in matches]<\/p>\n<p>    print(numbers)  # \u8f93\u51fa: [12, 34, 56]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u63d0\u53d6\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u6570\u5b57\u5e76\u8f6c\u6362\u4e3a\u6574\u578b\u5217\u8868\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e09\u3001\u4f7f\u7528\u81ea\u5b9a\u4e49\u51fd\u6570<\/h2>\n<\/p>\n<p><p>\u6709\u65f6\u5019\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u4e00\u4e2a\u66f4\u52a0\u901a\u7528\u7684\u89e3\u51b3\u65b9\u6848\uff0c\u8fd9\u65f6\u53ef\u4ee5\u5b9a\u4e49\u4e00\u4e2a\u81ea\u5b9a\u4e49\u51fd\u6570\u6765\u5904\u7406\u5404\u79cd\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\u7684\u60c5\u51b5\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u57fa\u672c\u51fd\u6570<\/h3>\n<\/p>\n<p><p>\u4e0b\u9762\u662f\u4e00\u4e2a\u57fa\u672c\u7684\u81ea\u5b9a\u4e49\u51fd\u6570\uff0c\u5b83\u80fd\u5904\u7406\u7b80\u5355\u7684\u5b57\u7b26\u4e32\u5230\u6574\u578b\u7684\u8f6c\u6362\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def str_to_int(s):<\/p>\n<p>    try:<\/p>\n<p>        return int(s)<\/p>\n<p>    except ValueError:<\/p>\n<p>        return None<\/p>\n<p>number_str = &quot;456&quot;<\/p>\n<p>number_int = str_to_int(number_str)<\/p>\n<p>print(number_int)  # \u8f93\u51fa: 456<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5904\u7406\u590d\u6742\u5b57\u7b26\u4e32<\/h3>\n<\/p>\n<p><p>\u53ef\u4ee5\u6269\u5c55\u8fd9\u4e2a\u51fd\u6570\uff0c\u4f7f\u5176\u80fd\u5904\u7406\u5305\u542b\u7279\u6b8a\u5b57\u7b26\u7684\u590d\u6742\u5b57\u7b26\u4e32\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">def str_to_int(s):<\/p>\n<p>    import re<\/p>\n<p>    s = s.replace(&quot;,&quot;, &quot;&quot;).strip()<\/p>\n<p>    matches = re.findall(r&#39;\\d+&#39;, s)<\/p>\n<p>    if matches:<\/p>\n<p>        return int(matches[0])<\/p>\n<p>    return None<\/p>\n<p>number_str = &quot; 1,234abc&quot;<\/p>\n<p>number_int = str_to_int(number_str)<\/p>\n<p>print(number_int)  # \u8f93\u51fa: 1234<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u901a\u8fc7\u8fd9\u79cd\u65b9\u5f0f\uff0c\u53ef\u4ee5\u5904\u7406\u66f4\u591a\u590d\u6742\u7684\u5b57\u7b26\u4e32\u60c5\u51b5\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u56db\u3001\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93<\/h2>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u573a\u666f\u4e2d\uff0c\u53ef\u80fd\u4f1a\u6709\u66f4\u590d\u6742\u7684\u5b57\u7b26\u4e32\u89e3\u6790\u9700\u6c42\uff0c\u53ef\u4ee5\u8003\u8651\u4f7f\u7528\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982<code>pandas<\/code>\u6216<code>numpy<\/code>\uff0c\u6765\u5904\u7406\u5927\u89c4\u6a21\u6570\u636e\u8f6c\u6362\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528pandas<\/h3>\n<\/p>\n<p><p><code>pandas<\/code>\u5e93\u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u6570\u636e\u5904\u7406\u529f\u80fd\uff0c\u7279\u522b\u9002\u7528\u4e8e\u5927\u6570\u636e\u96c6\u7684\u8f6c\u6362\u64cd\u4f5c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>data = pd.Series([&quot;123&quot;, &quot;456&quot;, &quot;789&quot;])<\/p>\n<p>data_int = data.astype(int)<\/p>\n<p>print(data_int)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u975e\u5e38\u9002\u5408\u5904\u7406\u5927\u89c4\u6a21\u7684\u5b57\u7b26\u4e32\u8f6c\u6362\u64cd\u4f5c\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528numpy<\/h3>\n<\/p>\n<p><p><code>numpy<\/code>\u5e93\u540c\u6837\u63d0\u4f9b\u4e86\u9ad8\u6548\u7684\u6570\u503c\u8ba1\u7b97\u529f\u80fd\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import numpy as np<\/p>\n<p>data = np.array([&quot;123&quot;, &quot;456&quot;, &quot;789&quot;])<\/p>\n<p>data_int = data.astype(int)<\/p>\n<p>print(data_int)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u540c\u6837\u9002\u7528\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u7684\u5904\u7406\uff0c\u5e76\u4e14\u5728\u6027\u80fd\u4e0a\u8868\u73b0\u4f18\u8d8a\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e94\u3001\u6ce8\u610f\u4e8b\u9879<\/h2>\n<\/p>\n<p><p>\u5728\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u6570\u636e\u6e05\u6d17<\/h3>\n<\/p>\n<p><p>\u786e\u4fdd\u5b57\u7b26\u4e32\u4e2d\u7684\u6570\u636e\u662f\u5e72\u51c0\u7684\uff0c\u5373\u6ca1\u6709\u65e0\u5173\u7684\u5b57\u7b26\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u9884\u5904\u7406\u6b65\u9aa4\u6765\u5b9e\u73b0\uff0c\u5982\u53bb\u9664\u7a7a\u683c\u3001\u9017\u53f7\u7b49\u3002<\/p>\n<\/p>\n<p><h3>2\u3001\u5f02\u5e38\u5904\u7406<\/h3>\n<\/p>\n<p><p>\u59cb\u7ec8\u8981\u8003\u8651\u5230\u53ef\u80fd\u7684\u5f02\u5e38\u60c5\u51b5\uff0c\u5982\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u975e\u6570\u5b57\u5b57\u7b26\u3002\u901a\u8fc7\u5f02\u5e38\u5904\u7406\u673a\u5236\uff0c\u53ef\u4ee5\u907f\u514d\u7a0b\u5e8f\u5d29\u6e83\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u6027\u80fd\u4f18\u5316<\/h3>\n<\/p>\n<p><p>\u5bf9\u4e8e\u5927\u89c4\u6a21\u6570\u636e\u7684\u8f6c\u6362\uff0c\u9009\u62e9\u9002\u5f53\u7684\u65b9\u6cd5\u548c\u5de5\u5177\uff0c\u5982<code>pandas<\/code>\u6216<code>numpy<\/code>\uff0c\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u6027\u80fd\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0c\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\u662f\u4e00\u4e2a\u5e38\u89c1\u4e14\u91cd\u8981\u7684\u64cd\u4f5c\u3002\u901a\u8fc7\u4f7f\u7528<code>int()<\/code>\u51fd\u6570\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u3001\u81ea\u5b9a\u4e49\u51fd\u6570\u4ee5\u53ca\u7b2c\u4e09\u65b9\u5e93\uff0c\u53ef\u4ee5\u9ad8\u6548\u5730\u5904\u7406\u5404\u79cd\u5b57\u7b26\u4e32\u8f6c\u6362\u9700\u6c42\u3002\u59cb\u7ec8\u6ce8\u610f\u6570\u636e\u6e05\u6d17\u548c\u5f02\u5e38\u5904\u7406\uff0c\u4ee5\u786e\u4fdd\u8f6c\u6362\u64cd\u4f5c\u7684\u53ef\u9760\u6027\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\u5904\u7406\u5b57\u7b26\u4e32\u5230\u6574\u578b\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>int()<\/code>\u51fd\u6570\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\u3002\u5982\u679c\u5b57\u7b26\u4e32\u662f\u6709\u6548\u7684\u6570\u5b57\u683c\u5f0f\uff0c\u51fd\u6570\u4f1a\u6210\u529f\u8fd4\u56de\u4e00\u4e2a\u6574\u578b\uff1b\u5982\u679c\u5b57\u7b26\u4e32\u5305\u542b\u975e\u6570\u5b57\u5b57\u7b26\uff0c\u51fd\u6570\u5c06\u629b\u51fa<code>ValueError<\/code>\u5f02\u5e38\u3002\u4f8b\u5982\uff0c<code>int(&quot;123&quot;)<\/code>\u4f1a\u8fd4\u56de\u6574\u578b123\uff0c\u800c<code>int(&quot;abc&quot;)<\/code>\u4f1a\u5f15\u53d1\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u786e\u4fdd\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u662f\u53ef\u8f6c\u6362\u7684\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<p><strong>\u5728\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u5982\u4f55\u5904\u7406\u5f02\u5e38\uff1f<\/strong><br \/>\u4f7f\u7528<code>try<\/code>\u548c<code>except<\/code>\u8bed\u53e5\u53ef\u4ee5\u6709\u6548\u5730\u5904\u7406\u5728\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\u65f6\u53ef\u80fd\u9047\u5230\u7684\u5f02\u5e38\u3002\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1\u7a0b\u5e8f\u7684\u7a33\u5b9a\u6027\u3002\u793a\u4f8b\u4ee3\u7801\u5982\u4e0b\uff1a  <\/p>\n<pre><code class=\"language-python\">try:\n    number = int(&quot;123a&quot;)\nexcept ValueError:\n    print(&quot;\u65e0\u6cd5\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6574\u578b\uff0c\u8bf7\u786e\u4fdd\u5b57\u7b26\u4e32\u53ea\u5305\u542b\u6570\u5b57\u3002&quot;)\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u5f0f\u5141\u8bb8\u4f60\u6355\u83b7\u5e76\u5904\u7406\u9519\u8bef\uff0c\u800c\u4e0d\u662f\u8ba9\u7a0b\u5e8f\u76f4\u63a5\u5d29\u6e83\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u8fdb\u884c\u5b57\u7b26\u4e32\u5230\u6574\u578b\u7684\u8f6c\u6362\uff1f<\/strong><br \/>\u9664\u4e86\u4f7f\u7528<code>int()<\/code>\u51fd\u6570\uff0c\u8fd8\u6709\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u7c7b\u4f3c\u7684\u529f\u80fd\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>float()<\/code>\u51fd\u6570\u5148\u5c06\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u6d6e\u70b9\u6570\uff0c\u518d\u8f6c\u6362\u4e3a\u6574\u578b\uff0c\u4f46\u8fd9\u79cd\u65b9\u6cd5\u53ef\u80fd\u4f1a\u5bfc\u81f4\u7cbe\u5ea6\u635f\u5931\u3002\u4e00\u822c\u6765\u8bf4\uff0c\u76f4\u63a5\u4f7f\u7528<code>int()<\/code>\u662f\u66f4\u4e3a\u63a8\u8350\u7684\u65b9\u5f0f\uff0c\u5c24\u5176\u662f\u5728\u5904\u7406\u660e\u786e\u7684\u6574\u6570\u503c\u65f6\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c06\u5b57\u7b26\u4e32\u7c7b\u578b\u8f6c\u6362\u4e3a\u6574\u578b\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5982\u4f7f\u7528int()\u51fd\u6570\u3001\u5904\u7406\u53ef\u80fd\u7684\u5f02\u5e38\u3001\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\u7b49\u3002\u5176\u4e2d\uff0c\u6700\u5e38 [&hellip;]","protected":false},"author":3,"featured_media":1138105,"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\/1138101"}],"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=1138101"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1138101\/revisions"}],"predecessor-version":[{"id":1138111,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1138101\/revisions\/1138111"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1138105"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1138101"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1138101"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1138101"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}