{"id":974878,"date":"2024-12-27T06:08:44","date_gmt":"2024-12-26T22:08:44","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/974878.html"},"modified":"2024-12-27T06:08:46","modified_gmt":"2024-12-26T22:08:46","slug":"%e5%a6%82%e4%bd%95%e7%94%a8python%e8%a1%a8%e7%a4%ba33","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/974878.html","title":{"rendered":"\u5982\u4f55\u7528python\u8868\u793a33"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24200401\/3d71a5ba-dad4-47c7-8571-697b34863e57.webp\" alt=\"\u5982\u4f55\u7528python\u8868\u793a33\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\uff0c\u8868\u793a\u6570\u5b5733\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u76f4\u63a5\u4f7f\u7528\u6574\u6570\u3001\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u7b49\u8fdb\u5236\u8868\u793a\u6cd5\u3002\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u662f\u76f4\u63a5\u4f7f\u7528\u6574\u6570\u8868\u793a\u6cd5\u3002<\/strong> \u8fd9\u79cd\u76f4\u63a5\u7684\u65b9\u6cd5\u65e2\u7b80\u5355\u53c8\u76f4\u89c2\uff0c\u9002\u7528\u4e8e\u7edd\u5927\u591a\u6570\u9700\u8981\u5904\u7406\u6574\u6570\u7684\u573a\u666f\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u8fd9\u4e9b\u4e0d\u540c\u7684\u8868\u793a\u65b9\u6cd5\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001\u6574\u6570\u8868\u793a<\/p>\n<\/p>\n<p><p>\u5728Python\u4e2d\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u76f4\u63a5\u4f7f\u7528\u6574\u6570\u6765\u8868\u793a33\u3002\u6574\u6570\u8868\u793a\u6cd5\u662f\u6700\u5e38\u7528\u7684\u8868\u793a\u6cd5\uff0c\u56e0\u4e3a\u5b83\u6700\u76f4\u89c2\u3001\u6613\u4e8e\u7406\u89e3\u3002\u53ef\u4ee5\u76f4\u63a5\u5728\u4ee3\u7801\u4e2d\u5199\u4f5c<code>33<\/code>\uff0c\u8fd9\u662f\u9ed8\u8ba4\u7684\u5341\u8fdb\u5236\u8868\u793a\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">number = 33<\/p>\n<p>print(number)  # \u8f93\u51fa: 33<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u3001\u4e8c\u8fdb\u5236\u8868\u793a<\/p>\n<\/p>\n<p><p>Python\u5141\u8bb8\u4f7f\u7528\u4e8c\u8fdb\u5236\u6765\u8868\u793a\u6574\u6570\u3002\u4e8c\u8fdb\u5236\u8868\u793a\u6cd5\u4ee5<code>0b<\/code>\u6216<code>0B<\/code>\u5f00\u5934\uff0c\u540e\u8ddf\u4e8c\u8fdb\u5236\u6570\u3002\u5728\u4e8c\u8fdb\u5236\u4e2d\uff0c33\u7684\u8868\u793a\u662f<code>100001<\/code>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">binary_number = 0b100001<\/p>\n<p>print(binary_number)  # \u8f93\u51fa: 33<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e8c\u8fdb\u5236\u8868\u793a\u6cd5\u5728\u9700\u8981\u8fdb\u884c\u4f4d\u64cd\u4f5c\u6216\u4f18\u5316\u5185\u5b58\u4f7f\u7528\u65f6\u7279\u522b\u6709\u7528\u3002\u5b83\u5728\u8ba1\u7b97\u673a\u79d1\u5b66\u4e2d\u662f\u6700\u57fa\u672c\u7684\u6570\u5236\uff0c\u56e0\u4e3a\u8ba1\u7b97\u673a\u5185\u90e8\u662f\u4ee5\u4e8c\u8fdb\u5236\u5f62\u5f0f\u5b58\u50a8\u548c\u5904\u7406\u6570\u636e\u7684\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u516b\u8fdb\u5236\u8868\u793a<\/p>\n<\/p>\n<p><p>\u516b\u8fdb\u5236\u8868\u793a\u6cd5\u4ee5<code>0o<\/code>\u6216<code>0O<\/code>\u5f00\u5934\uff0c\u540e\u8ddf\u516b\u8fdb\u5236\u6570\u3002\u5728\u516b\u8fdb\u5236\u4e2d\uff0c33\u8868\u793a\u4e3a<code>41<\/code>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">octal_number = 0o41<\/p>\n<p>print(octal_number)  # \u8f93\u51fa: 33<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u867d\u7136\u516b\u8fdb\u5236\u5728\u73b0\u4ee3\u7f16\u7a0b\u4e2d\u4e0d\u5982\u4e8c\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u5e38\u7528\uff0c\u4f46\u5728\u67d0\u4e9b\u9886\u57df\uff0c\u5982\u8ba1\u7b97\u673a\u56fe\u5f62\u5b66\u548c\u6570\u5b57\u7535\u8def\u8bbe\u8ba1\u4e2d\uff0c\u516b\u8fdb\u5236\u4ecd\u7136\u6709\u5176\u5e94\u7528\u573a\u666f\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5341\u516d\u8fdb\u5236\u8868\u793a<\/p>\n<\/p>\n<p><p>\u5341\u516d\u8fdb\u5236\u8868\u793a\u6cd5\u4ee5<code>0x<\/code>\u6216<code>0X<\/code>\u5f00\u5934\uff0c\u540e\u8ddf\u5341\u516d\u8fdb\u5236\u6570\u3002\u5728\u5341\u516d\u8fdb\u5236\u4e2d\uff0c33\u8868\u793a\u4e3a<code>21<\/code>\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">hexadecimal_number = 0x21<\/p>\n<p>print(hexadecimal_number)  # \u8f93\u51fa: 33<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5341\u516d\u8fdb\u5236\u8868\u793a\u6cd5\u5e38\u7528\u4e8e\u9700\u8981\u4e0e\u4f4e\u7ea7\u8ba1\u7b97\u673a\u786c\u4ef6\u76f4\u63a5\u4ea4\u4e92\u7684\u573a\u666f\uff0c\u4f8b\u5982\u64cd\u4f5c\u7cfb\u7edf\u5f00\u53d1\u3001\u5d4c\u5165\u5f0f\u7cfb\u7edf\u4ee5\u53ca\u7f51\u7edc\u7f16\u7a0b\u4e2d\u3002\u5728\u8fd9\u4e9b\u9886\u57df\uff0c\u5341\u516d\u8fdb\u5236\u80fd\u591f\u4ee5\u66f4\u7d27\u51d1\u7684\u5f62\u5f0f\u8868\u793a\u6570\u636e\u3002<\/p>\n<\/p>\n<p><p>\u4e94\u3001\u603b\u7ed3<\/p>\n<\/p>\n<p><p>\u603b\u7ed3\u6765\u8bf4\uff0cPython\u63d0\u4f9b\u4e86\u591a\u79cd\u8868\u793a\u6574\u6570\u7684\u65b9\u6cd5\uff0c\u5305\u62ec<strong>\u76f4\u63a5\u7684\u6574\u6570\u8868\u793a\u3001\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u8868\u793a\u6cd5<\/strong>\u3002\u6839\u636e\u4e0d\u540c\u7684\u5e94\u7528\u573a\u666f\u548c\u9700\u6c42\uff0c\u9009\u62e9\u5408\u9002\u7684\u8868\u793a\u65b9\u6cd5\u80fd\u591f\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u6548\u7387\u3002\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528\u76f4\u63a5\u7684\u6574\u6570\u8868\u793a\u662f\u6700\u7b80\u5355\u548c\u6700\u5e38\u7528\u7684\u65b9\u5f0f\uff0c\u4f46\u5728\u7279\u5b9a\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\u53ef\u80fd\u4f1a\u5e26\u6765\u66f4\u5927\u7684\u7075\u6d3b\u6027\u548c\u4fbf\u5229\u6027\u3002\u901a\u8fc7\u5bf9\u8fd9\u4e9b\u8868\u793a\u65b9\u6cd5\u7684\u7406\u89e3\u548c\u5b9e\u8df5\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u638c\u63e1Python\u7684\u6570\u503c\u5904\u7406\u80fd\u529b\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u7528Python\u5982\u4f55\u8868\u793a\u6570\u5b5733\u7684\u4e0d\u540c\u65b9\u5f0f\uff1f<\/strong><br \/>\u5728Python\u4e2d\uff0c\u6570\u5b5733\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u5f0f\u8868\u793a\uff0c\u4f8b\u5982\u76f4\u63a5\u4f7f\u7528\u6574\u6570\u5f62\u5f0f<code>33<\/code>\uff0c\u4e5f\u53ef\u4ee5\u4f7f\u7528\u53d8\u91cf\u8d4b\u503c\u7684\u65b9\u5f0f\uff0c\u5982<code>number = 33<\/code>\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u5341\u516d\u8fdb\u5236\u8868\u793a\u6cd5<code>0x21<\/code>\uff08\u5341\u516d\u8fdb\u5236\u768433\uff09\u6765\u8868\u793a\u3002\u4f7f\u7528<code>print()<\/code>\u51fd\u6570\u53ef\u4ee5\u8f7b\u677e\u8f93\u51fa\u8fd9\u4e9b\u6570\u5b57\u3002<\/p>\n<p><strong>\u5728Python\u4e2d\u5982\u4f55\u5c0633\u8f6c\u6362\u4e3a\u5176\u4ed6\u8fdb\u5236\uff1f<\/strong><br \/>\u5982\u679c\u9700\u8981\u5c0633\u8f6c\u6362\u4e3a\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u6216\u5341\u516d\u8fdb\u5236\uff0c\u53ef\u4ee5\u4f7f\u7528\u5185\u7f6e\u51fd\u6570\u3002\u4f7f\u7528<code>bin(33)<\/code>\u53ef\u4ee5\u5f97\u5230<code>0b100001<\/code>\u7684\u4e8c\u8fdb\u5236\u8868\u793a\uff0c<code>oct(33)<\/code>\u5f97\u5230<code>0o41<\/code>\u7684\u516b\u8fdb\u5236\u8868\u793a\uff0c\u800c<code>hex(33)<\/code>\u5219\u8fd4\u56de<code>0x21<\/code>\u7684\u5341\u516d\u8fdb\u5236\u8868\u793a\u3002\u8fd9\u4e9b\u8868\u793a\u65b9\u5f0f\u5728\u5904\u7406\u4e0d\u540c\u6570\u636e\u7c7b\u578b\u65f6\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728Python\u4e2d\u5bf933\u8fdb\u884c\u6570\u5b66\u8fd0\u7b97\uff1f<\/strong><br \/>Python\u652f\u6301\u591a\u79cd\u6570\u5b66\u8fd0\u7b97\uff0c\u4f8b\u5982\u52a0\u6cd5\u3001\u51cf\u6cd5\u3001\u4e58\u6cd5\u548c\u9664\u6cd5\u3002\u4f60\u53ef\u4ee5\u5bf9\u6570\u5b5733\u8fdb\u884c\u8fd0\u7b97\uff0c\u6bd4\u5982<code>33 + 10<\/code>\u5c06\u8fd4\u56de43\uff0c<code>33 * 2<\/code>\u5c06\u8fd4\u56de66\u3002\u6b64\u5916\uff0c\u4f7f\u7528Python\u7684<code>math<\/code>\u6a21\u5757\u53ef\u4ee5\u8fdb\u884c\u66f4\u590d\u6742\u7684\u6570\u5b66\u8ba1\u7b97\uff0c\u5982\u5e73\u65b9\u6839\u3001\u4e09\u89d2\u51fd\u6570\u7b49\uff0c\u8fd9\u4f7f\u5f97\u5904\u7406\u6570\u5b57\u66f4\u52a0\u7075\u6d3b\u548c\u5f3a\u5927\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\uff0c\u8868\u793a\u6570\u5b5733\u7684\u65b9\u6cd5\u6709\u591a\u79cd\uff0c\u5305\u62ec\u76f4\u63a5\u4f7f\u7528\u6574\u6570\u3001\u4e8c\u8fdb\u5236\u3001\u516b\u8fdb\u5236\u548c\u5341\u516d\u8fdb\u5236\u7b49\u8fdb\u5236\u8868\u793a\u6cd5\u3002\u6700\u5e38\u89c1\u7684\u65b9 [&hellip;]","protected":false},"author":3,"featured_media":974886,"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\/974878"}],"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=974878"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/974878\/revisions"}],"predecessor-version":[{"id":974888,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/974878\/revisions\/974888"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/974886"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=974878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=974878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=974878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}