{"id":964933,"date":"2024-12-27T04:33:07","date_gmt":"2024-12-26T20:33:07","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/964933.html"},"modified":"2024-12-27T04:33:10","modified_gmt":"2024-12-26T20:33:10","slug":"python%e5%a6%82%e4%bd%95%e8%be%93%e5%87%ba8%e8%bf%9b%e5%88%b6","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/964933.html","title":{"rendered":"python\u5982\u4f55\u8f93\u51fa8\u8fdb\u5236"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24181454\/a69888c8-bdb6-4af4-93ff-7ee07a6d015a.webp\" alt=\"python\u5982\u4f55\u8f93\u51fa8\u8fdb\u5236\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u8f93\u51fa8\u8fdb\u5236\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u4f7f\u7528\u5185\u7f6e\u51fd\u6570<code>oct()<\/code>\u3001\u683c\u5f0f\u5316\u5b57\u7b26\u4e32<code>format()<\/code>\u3001\u4ee5\u53ca\u4f7f\u7528<code>f-string<\/code>\u3002\u4f7f\u7528\u5185\u7f6e\u51fd\u6570<code>oct()<\/code>\u662f\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u3002<\/strong><\/p>\n<\/p>\n<p><p>Python\u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u5f0f\u6765\u5c06\u6574\u6570\u8868\u793a\u4e3a8\u8fdb\u5236\u3002\u4e0b\u9762\u6211\u5c06\u8be6\u7ec6\u63cf\u8ff0\u8fd9\u4e9b\u65b9\u6cd5\uff0c\u5e76\u63d0\u4f9b\u76f8\u5173\u793a\u4f8b\u548c\u4f7f\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u4f7f\u7528<code>oct()<\/code>\u51fd\u6570<\/p>\n<\/p>\n<p><p><code>oct()<\/code>\u51fd\u6570\u662fPython\u5185\u7f6e\u51fd\u6570\u4e4b\u4e00\uff0c\u80fd\u591f\u5c06\u4e00\u4e2a\u6574\u6570\u8f6c\u6362\u4e3a8\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u5b83\u7684\u7528\u6cd5\u975e\u5e38\u7b80\u5355\uff0c\u76f4\u63a5\u5c06\u6574\u6570\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9<code>oct()<\/code>\u51fd\u6570\u5373\u53ef\u3002\u8fd4\u56de\u7684\u5b57\u7b26\u4e32\u4ee5\u201c0o\u201d\u5f00\u5934\uff0c\u8868\u793a\u8fd9\u662f\u4e00\u4e2a8\u8fdb\u5236\u6570\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number = 10<\/p>\n<p>octal_number = oct(number)<\/p>\n<p>print(octal_number)  # \u8f93\u51fa\u4e3a\uff1a0o12<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u597d\u5904\u662f\u7b80\u5355\u76f4\u63a5\uff0c\u9002\u7528\u4e8e\u9700\u8981\u5feb\u901f\u5c06\u6574\u6570\u8f6c\u6362\u4e3a8\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u573a\u666f\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u4f7f\u7528\u683c\u5f0f\u5316\u5b57\u7b26\u4e32<code>format()<\/code><\/p>\n<\/p>\n<p><p>Python\u7684<code>format()<\/code>\u51fd\u6570\u63d0\u4f9b\u4e86\u4e00\u79cd\u7075\u6d3b\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u5f0f\u3002\u901a\u8fc7\u5728\u683c\u5f0f\u5b57\u7b26\u4e32\u4e2d\u6307\u5b9a<code>&#39;o&#39;<\/code>\u6807\u8bc6\u7b26\uff0c\u53ef\u4ee5\u5c06\u6574\u6570\u683c\u5f0f\u5316\u4e3a8\u8fdb\u5236\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number = 10<\/p>\n<p>octal_number = format(number, &#39;o&#39;)<\/p>\n<p>print(octal_number)  # \u8f93\u51fa\u4e3a\uff1a12<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u79cd\u65b9\u6cd5\u7684\u4f18\u52bf\u5728\u4e8e\u53ef\u4ee5\u8fdb\u884c\u66f4\u591a\u7684\u683c\u5f0f\u5316\u64cd\u4f5c\uff0c\u6bd4\u5982\u5728\u524d\u9762\u8865\u96f6\u3001\u6307\u5b9a\u5bbd\u5ea6\u7b49\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u4f7f\u7528<code>f-string<\/code><\/p>\n<\/p>\n<p><p>\u5728Python 3.6\u53ca\u4ee5\u4e0a\u7248\u672c\u4e2d\uff0c<code>f-string<\/code>\u63d0\u4f9b\u4e86\u4e00\u79cd\u66f4\u4e3a\u7b80\u6d01\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u5316\u65b9\u5f0f\u3002\u901a\u8fc7\u5728\u5927\u62ec\u53f7\u4e2d\u4f7f\u7528<code>:o<\/code>\uff0c\u53ef\u4ee5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a8\u8fdb\u5236\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number = 10<\/p>\n<p>octal_number = f&quot;{number:o}&quot;<\/p>\n<p>print(octal_number)  # \u8f93\u51fa\u4e3a\uff1a12<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p><code>f-string<\/code>\u65b9\u5f0f\u7b80\u5355\u660e\u4e86\uff0c\u975e\u5e38\u9002\u5408\u5728\u9700\u8981\u52a8\u6001\u63d2\u5165\u53d8\u91cf\u503c\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5e38\u89c1\u5e94\u7528\u573a\u666f\u4e0e\u6ce8\u610f\u4e8b\u9879<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6570\u636e\u5904\u7406\u4e0e\u8f6c\u6362<\/strong><br \/>\u5728\u6570\u636e\u5904\u7406\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u5bf9\u4e0d\u540c\u8fdb\u5236\u7684\u6570\u503c\u8fdb\u884c\u8f6c\u6362\uff0c\u4ee5\u9002\u5e94\u4e0d\u540c\u7684\u7cfb\u7edf\u8981\u6c42\u3002\u5c24\u5176\u5728\u5904\u7406\u4f4e\u5c42\u6b21\u6570\u636e\u64cd\u4f5c\u65f6\uff0c8\u8fdb\u5236\u6570\u5e38\u88ab\u4f7f\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6587\u4ef6\u6743\u9650\u8868\u793a<\/strong><br \/>\u5728Unix\u548cLinux\u7cfb\u7edf\u4e2d\uff0c\u6587\u4ef6\u6743\u9650\u901a\u5e38\u4ee58\u8fdb\u5236\u8868\u793a\u3002\u901a\u8fc7Python\u5c06\u6743\u9650\u503c\u8f6c\u6362\u4e3a8\u8fdb\u5236\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u8fdb\u884c\u6743\u9650\u8ba1\u7b97\u4e0e\u8bbe\u7f6e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u907f\u514d\u6df7\u6dc6<\/strong><br \/>\u5728\u4f7f\u75288\u8fdb\u5236\u8868\u793a\u65f6\uff0c\u6ce8\u610f\u907f\u514d\u4e0e\u5176\u4ed6\u8fdb\u5236\u8868\u793a\u7684\u6df7\u6dc6\u3002\u5c24\u5176\u662f\u5728\u8f93\u51fa\u7ed3\u679c\u4e2d\uff0c\u786e\u4fdd\u7406\u89e3\u201c0o\u201d\u524d\u7f00\u7684\u610f\u4e49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u6df1\u5165\u7406\u89e3Python\u4e2d8\u8fdb\u5236\u8868\u793a\u7684\u5e95\u5c42\u673a\u5236<\/p>\n<\/p>\n<p><p>\u4e3a\u4e86\u66f4\u6df1\u5165\u5730\u7406\u89e3Python\u4e2d8\u8fdb\u5236\u8868\u793a\u7684\u5de5\u4f5c\u673a\u5236\uff0c\u6211\u4eec\u53ef\u4ee5\u4ecePython\u7684\u6570\u503c\u7c7b\u578b\u3001\u5185\u5b58\u7ba1\u7406\u3001\u4ee5\u53ca\u5e95\u5c42\u5b9e\u73b0\u7b49\u89d2\u5ea6\u8fdb\u884c\u5206\u6790\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u6570\u503c\u7c7b\u578b\u4e0e\u5185\u5b58\u7ba1\u7406<\/strong><br \/>Python\u4e2d\u7684\u6574\u6570\u7c7b\u578b\u662f\u52a8\u6001\u7684\uff0c\u5373\u5728\u8fd0\u884c\u65f6\u6839\u636e\u5177\u4f53\u6570\u503c\u7684\u5927\u5c0f\u81ea\u52a8\u8c03\u6574\u5b58\u50a8\u7a7a\u95f4\u3002\u5728\u8f6c\u6362\u4e3a8\u8fdb\u5236\u65f6\uff0cPython\u5e76\u4e0d\u6539\u53d8\u6570\u503c\u672c\u8eab\u7684\u5b58\u50a8\uff0c\u53ea\u662f\u6539\u53d8\u5176\u8868\u793a\u65b9\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5e95\u5c42\u5b9e\u73b0<\/strong><br \/>Python\u7684<code>oct()<\/code>\u51fd\u6570\u5728\u5e95\u5c42\u901a\u8fc7\u4f4d\u64cd\u4f5c\u5b9e\u73b0\u5c06\u5341\u8fdb\u5236\u8f6c\u6362\u4e3a8\u8fdb\u5236\u3002\u5177\u4f53\u6765\u8bf4\uff0c\u662f\u901a\u8fc7\u4e0d\u65ad\u5730\u5c06\u6570\u503c\u9664\u4ee58\u5e76\u8bb0\u5f55\u4f59\u6570\u7684\u65b9\u5f0f\u8fdb\u884c\u8f6c\u6362\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6027\u80fd\u8003\u91cf<\/strong><br \/>\u5728\u5927\u591a\u6570\u5e94\u7528\u573a\u666f\u4e0b\uff0c\u6570\u503c\u8f6c\u6362\u7684\u6027\u80fd\u5e76\u4e0d\u662f\u74f6\u9888\u3002\u4f46\u5728\u5bf9\u6027\u80fd\u8981\u6c42\u8f83\u9ad8\u7684\u573a\u666f\u4e2d\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u8fdb\u884c\u8f6c\u6362\u4ecd\u7136\u662f\u4e00\u4e2a\u503c\u5f97\u8003\u8651\u7684\u95ee\u9898\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u516d\u3001\u4e0e\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u7684\u5bf9\u6bd4<\/p>\n<\/p>\n<p><p>\u5728\u5176\u4ed6\u7f16\u7a0b\u8bed\u8a00\u4e2d\uff0c8\u8fdb\u5236\u8868\u793a\u4e5f\u5f88\u5e38\u89c1\u3002\u4e0d\u540c\u8bed\u8a00\u5bf98\u8fdb\u5236\u7684\u652f\u6301\u65b9\u5f0f\u53ef\u80fd\u6709\u6240\u4e0d\u540c\uff0c\u8fd9\u91cc\u6211\u4eec\u4ee5C\u3001Java\u548cJavaScript\u4e3a\u4f8b\u8fdb\u884c\u5bf9\u6bd4\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>C\u8bed\u8a00<\/strong><br \/>\u5728C\u8bed\u8a00\u4e2d\uff0c8\u8fdb\u5236\u6570\u4ee5\u201c0\u201d\u5f00\u5934\u8868\u793a\u3002\u901a\u8fc7<code>printf<\/code>\u51fd\u6570\u53ef\u4ee5\u5c06\u6574\u6570\u8f93\u51fa\u4e3a8\u8fdb\u5236\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-c\">#include &lt;stdio.h&gt;<\/p>\n<p>int m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>n() {<\/p>\n<p>    int number = 10;<\/p>\n<p>    printf(&quot;%o\\n&quot;, number);  \/\/ \u8f93\u51fa\u4e3a\uff1a12<\/p>\n<p>    return 0;<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>Java\u8bed\u8a00<\/strong><br \/>Java\u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7<code>Integer.toOctalString()<\/code>\u65b9\u6cd5\u5c06\u6574\u6570\u8f6c\u6362\u4e3a8\u8fdb\u5236\u5b57\u7b26\u4e32\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-java\">public class Main {<\/p>\n<p>    public static void main(String[] args) {<\/p>\n<p>        int number = 10;<\/p>\n<p>        String octalNumber = Integer.toOctalString(number);<\/p>\n<p>        System.out.println(octalNumber);  \/\/ \u8f93\u51fa\u4e3a\uff1a12<\/p>\n<p>    }<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li><strong>JavaScript\u8bed\u8a00<\/strong><br \/>\u5728JavaScript\u4e2d\uff0c\u901a\u8fc7<code>toString(8)<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5c06\u6570\u5b57\u8f6c\u6362\u4e3a8\u8fdb\u5236\u8868\u793a\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-javascript\">let number = 10;<\/p>\n<p>let octalNumber = number.toString(8);<\/p>\n<p>console.log(octalNumber);  \/\/ \u8f93\u51fa\u4e3a\uff1a12<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e03\u3001\u8fdb\u9636\u4f7f\u7528\u6280\u5de7<\/p>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u8fdb\u9636\u7684\u4f7f\u7528\u573a\u666f\uff0c\u4f8b\u5982\u6279\u91cf\u8f6c\u6362\u3001\u4e0e\u5176\u4ed6\u6570\u636e\u7ed3\u6784\u7ed3\u5408\u4f7f\u7528\u7b49\u3002<\/p>\n<\/p>\n<ol>\n<li><strong>\u6279\u91cf\u8f6c\u6362<\/strong><br \/>\u5728\u9700\u8981\u5bf9\u4e00\u7ec4\u6574\u6570\u8fdb\u884c\u6279\u91cf\u8f6c\u6362\u65f6\uff0c\u53ef\u4ee5\u7ed3\u5408\u5217\u8868\u751f\u6210\u5f0f\u6216<code>map()<\/code>\u51fd\u6570\u5b9e\u73b0\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">numbers = [10, 20, 30]<\/p>\n<p>octal_numbers = [oct(num) for num in numbers]<\/p>\n<p>print(octal_numbers)  # \u8f93\u51fa\u4e3a\uff1a[&#39;0o12&#39;, &#39;0o24&#39;, &#39;0o36&#39;]<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"2\">\n<li><strong>\u7ed3\u5408\u6570\u636e\u7ed3\u6784\u4f7f\u7528<\/strong><br \/>\u5728\u5904\u7406\u590d\u6742\u6570\u636e\u7ed3\u6784\u65f6\uff0c\u53ef\u80fd\u9700\u8981\u5c06\u5176\u4e2d\u7684\u6574\u6570\u5b57\u6bb5\u8f6c\u6362\u4e3a8\u8fdb\u5236\u3002\u4f8b\u5982\uff0c\u5728\u5b57\u5178\u4e2d\u5b58\u50a8\u6743\u9650\u4fe1\u606f\u65f6\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u6743\u9650\u503c\u8f6c\u6362\u4e3a8\u8fdb\u5236\u3002<\/li>\n<\/ol>\n<p><pre><code class=\"language-python\">file_permissions = {&#39;read&#39;: 4, &#39;write&#39;: 2, &#39;execute&#39;: 1}<\/p>\n<p>octal_permissions = {k: oct(v) for k, v in file_permissions.items()}<\/p>\n<p>print(octal_permissions)  # \u8f93\u51fa\u4e3a\uff1a{&#39;read&#39;: &#39;0o4&#39;, &#39;write&#39;: &#39;0o2&#39;, &#39;execute&#39;: &#39;0o1&#39;}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u516b\u3001\u603b\u7ed3\u4e0e\u6700\u4f73\u5b9e\u8df5<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u8f93\u51fa8\u8fdb\u5236\u7684\u65b9\u5f0f\u591a\u79cd\u591a\u6837\uff0c\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u5177\u4f53\u7684\u5e94\u7528\u573a\u666f\u548c\u4e2a\u4eba\u4e60\u60ef\u3002\u5728\u65e5\u5e38\u5f00\u53d1\u4e2d\uff0c\u63a8\u8350\u4f7f\u7528<code>oct()<\/code>\u51fd\u6570\u8fdb\u884c\u7b80\u5355\u7684\u6570\u503c\u8f6c\u6362\uff0c\u800c\u5728\u9700\u8981\u66f4\u590d\u6742\u7684\u683c\u5f0f\u5316\u64cd\u4f5c\u65f6\uff0c\u53ef\u4ee5\u9009\u62e9<code>format()<\/code>\u51fd\u6570\u6216<code>f-string<\/code>\u3002\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6cd5\uff0c\u7406\u89e3\u5176\u5e95\u5c42\u673a\u5236\u548c\u9002\u7528\u573a\u666f\u90fd\u662f\u786e\u4fdd\u4ee3\u7801\u6b63\u786e\u6027\u548c\u6548\u7387\u7684\u5173\u952e\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5c06\u5341\u8fdb\u5236\u6570\u8f6c\u6362\u4e3a\u516b\u8fdb\u5236\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u7684<code>oct()<\/code>\u51fd\u6570\u5c06\u5341\u8fdb\u5236\u6570\u8f6c\u6362\u4e3a\u516b\u8fdb\u5236\u3002\u8be5\u51fd\u6570\u63a5\u53d7\u4e00\u4e2a\u6574\u6570\u4f5c\u4e3a\u53c2\u6570\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u5b57\u7b26\u4e32\uff0c\u8868\u793a\u8be5\u6574\u6570\u7684\u516b\u8fdb\u5236\u5f62\u5f0f\u3002\u4f8b\u5982\uff0c<code>oct(10)<\/code>\u5c06\u8fd4\u56de<code>&#39;0o12&#39;<\/code>\uff0c\u8868\u793a\u5341\u8fdb\u5236\u768410\u5728\u516b\u8fdb\u5236\u4e0b\u7684\u8868\u793a\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u683c\u5f0f\u5316\u8f93\u51fa\u516b\u8fdb\u5236\u6570\uff1f<\/strong><br \/>\u5982\u679c\u5e0c\u671b\u4ee5\u7279\u5b9a\u683c\u5f0f\u8f93\u51fa\u516b\u8fdb\u5236\u6570\uff0c\u53ef\u4ee5\u4f7f\u7528\u683c\u5f0f\u5316\u5b57\u7b26\u4e32\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>format()<\/code>\u51fd\u6570\u6216f-string\u53ef\u4ee5\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u8f93\u51fa\u3002\u6bd4\u5982\uff0c<code>f&quot;{num:o}&quot;<\/code>\u4f1a\u5c06\u53d8\u91cf<code>num<\/code>\u7684\u503c\u4ee5\u516b\u8fdb\u5236\u5f62\u5f0f\u8f93\u51fa\u3002\u8fd9\u6837\u53ef\u4ee5\u5f88\u65b9\u4fbf\u5730\u8c03\u6574\u8f93\u51fa\u7684\u683c\u5f0f\u548c\u6837\u5f0f\u3002<\/p>\n<p><strong>Python\u662f\u5426\u652f\u6301\u8d1f\u6570\u7684\u516b\u8fdb\u5236\u8868\u793a\uff1f<\/strong><br \/>\u662f\u7684\uff0cPython\u53ef\u4ee5\u5904\u7406\u8d1f\u6570\u7684\u516b\u8fdb\u5236\u8868\u793a\u3002\u8d1f\u6570\u7684\u516b\u8fdb\u5236\u8868\u793a\u65b9\u5f0f\u548c\u6b63\u6570\u76f8\u540c\uff0c\u53ea\u662f\u5728\u6570\u503c\u524d\u52a0\u4e0a\u8d1f\u53f7\u3002\u4f8b\u5982\uff0c<code>oct(-10)<\/code>\u7684\u8f93\u51fa\u5c06\u662f<code>&#39;-0o12&#39;<\/code>\uff0c\u8868\u793a\u8d1f\u6570-10\u7684\u516b\u8fdb\u5236\u5f62\u5f0f\u3002\u65e0\u8bba\u662f\u6b63\u6570\u8fd8\u662f\u8d1f\u6570\uff0c\u4f7f\u7528<code>oct()<\/code>\u51fd\u6570\u90fd\u53ef\u4ee5\u8f7b\u677e\u83b7\u5f97\u5176\u516b\u8fdb\u5236\u8868\u793a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u8f93\u51fa8\u8fdb\u5236\u7684\u65b9\u6cd5\u4e3b\u8981\u6709\uff1a\u4f7f\u7528\u5185\u7f6e\u51fd\u6570oct()\u3001\u683c\u5f0f\u5316\u5b57\u7b26\u4e32format()\u3001\u4ee5\u53ca\u4f7f\u7528f-st [&hellip;]","protected":false},"author":3,"featured_media":964941,"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\/964933"}],"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=964933"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/964933\/revisions"}],"predecessor-version":[{"id":964942,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/964933\/revisions\/964942"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/964941"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=964933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=964933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=964933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}