{"id":951266,"date":"2024-12-27T00:55:26","date_gmt":"2024-12-26T16:55:26","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/951266.html"},"modified":"2024-12-27T00:55:29","modified_gmt":"2024-12-26T16:55:29","slug":"sublime-%e5%a6%82%e4%bd%95%e8%bf%90%e8%a1%8cpython","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/951266.html","title":{"rendered":"sublime \u5982\u4f55\u8fd0\u884cpython"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25085538\/06c4e142-2cef-4def-bf59-dca4fb093ea3.webp\" alt=\"sublime \u5982\u4f55\u8fd0\u884cpython\" \/><\/p>\n<p><p> <strong>\u8981\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u63d2\u4ef6\u3001\u8bbe\u7f6e\u6784\u5efa\u7cfb\u7edf\u7b49\u65b9\u5f0f\u5b9e\u73b0\u3002\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528Sublime Text\u5185\u7f6e\u7684\u6784\u5efa\u7cfb\u7edf\u3001\u5b89\u88c5Package Control\u63d2\u4ef6\u6765\u7ba1\u7406\u548c\u5b89\u88c5\u6240\u9700\u7684\u6269\u5c55\u5de5\u5177\u3001\u8bbe\u7f6ePython\u89e3\u91ca\u5668\u8def\u5f84\u3002\u4ee5\u4e0b\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5728Sublime Text\u4e2d\u914d\u7f6e\u548c\u8fd0\u884cPython\u4ee3\u7801\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e00\u3001\u5b89\u88c5Package Control<\/p>\n<\/p>\n<p><p>Sublime Text\u672c\u8eab\u6ca1\u6709\u5305\u7ba1\u7406\u529f\u80fd\uff0c\u9700\u8981\u901a\u8fc7Package Control\u6765\u7ba1\u7406\u63d2\u4ef6\u3002\u9996\u5148\uff0c\u6253\u5f00Sublime Text\uff0c\u6309\u4e0b\u5feb\u6377\u952e<code>Ctrl + ``\uff08\u53cd\u5f15\u53f7\uff09\u6216\u9009\u62e9\u83dc\u5355<\/code>View -&gt; Show Console`\u6253\u5f00\u63a7\u5236\u53f0\u3002\u7136\u540e\uff0c\u7c98\u8d34\u4ee5\u4e0b\u4ee3\u7801\u5e76\u6309\u4e0b\u56de\u8f66\u952e\u6267\u884c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import urllib.request,os,hashlib; h = &#39;8e3f22b5e11e5d4e980b9e3b0d7a4c0f5b1e0f85f8f9b6aa9b4d2a3f4e1a6a28&#39;; pf = &#39;Package Control.sublime-package&#39;; ipp = sublime.installed_packages_path(); urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler())); by = urllib.request.urlopen(&#39;http:\/\/packagecontrol.io\/&#39; + pf.replace(&#39; &#39;, &#39;%20&#39;)).read(); dh = hashlib.sha256(by).hexdigest(); open(os.path.join(ipp, pf), &#39;wb&#39;).write(by) if dh == h else None<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u91cd\u542fSublime Text\uff0cPackage Control\u5c31\u4f1a\u5b89\u88c5\u5b8c\u6210\u3002<\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u5b89\u88c5SublimeREPL\u63d2\u4ef6<\/p>\n<\/p>\n<p><p>SublimeREPL\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u63d2\u4ef6\uff0c\u53ef\u4ee5\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u548c\u5176\u4ed6\u8bed\u8a00\u7684\u4ee3\u7801\u3002\u5b89\u88c5Package Control\u540e\uff0c\u6309\u4e0b<code>Ctrl + Shift + P<\/code>\u6253\u5f00\u547d\u4ee4\u9762\u677f\uff0c\u8f93\u5165<code>Install Package<\/code>\u5e76\u9009\u62e9\uff0c\u63a5\u7740\u8f93\u5165<code>SublimeREPL<\/code>\u5e76\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><p>\u4e09\u3001\u914d\u7f6ePython\u6784\u5efa\u7cfb\u7edf<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00Sublime Text\uff0c\u9009\u62e9\u83dc\u5355\u680f\u4e2d\u7684<code>Tools -&gt; Build System -&gt; New Build System<\/code>\u3002<\/li>\n<li>\u5728\u6253\u5f00\u7684\u6587\u4ef6\u4e2d\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/li>\n<\/ol>\n<p><pre><code class=\"language-json\">{<\/p>\n<p>    &quot;cmd&quot;: [&quot;python3&quot;, &quot;-u&quot;, &quot;$file&quot;],<\/p>\n<p>    &quot;file_regex&quot;: &quot;^[ ]*File \\&quot;(...*?)\\&quot;, line ([0-9]*)&quot;,<\/p>\n<p>    &quot;selector&quot;: &quot;source.python&quot;,<\/p>\n<p>    &quot;encoding&quot;: &quot;utf-8&quot;,<\/p>\n<p>    &quot;variants&quot;:<\/p>\n<p>    [<\/p>\n<p>        {<\/p>\n<p>            &quot;name&quot;: &quot;Run&quot;,<\/p>\n<p>            &quot;cmd&quot;: [&quot;python3&quot;, &quot;-u&quot;, &quot;$file&quot;]<\/p>\n<p>        }<\/p>\n<p>    ]<\/p>\n<p>}<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ol start=\"3\">\n<li>\u4fdd\u5b58\u6587\u4ef6\uff0c\u547d\u540d\u4e3a<code>Python3.sublime-build<\/code>\u3002<\/li>\n<\/ol>\n<p><p><strong>\u6ce8\u610f\uff1a<\/strong> \u8bf7\u786e\u4fdd\u7cfb\u7edf\u4e2d\u5df2\u5b89\u88c5Python3\uff0c\u4e14\u5728\u547d\u4ee4\u884c\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528<code>python3<\/code>\u547d\u4ee4\u3002\u5982\u679c\u4f7f\u7528\u7684\u662fWindows\u7cfb\u7edf\uff0c\u53ef\u80fd\u9700\u8981\u5c06<code>cmd<\/code>\u4e2d\u7684<code>python3<\/code>\u66ff\u6362\u4e3a<code>python<\/code>\u3002<\/p>\n<\/p>\n<p><p>\u56db\u3001\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00\u4e00\u4e2aPython\u6587\u4ef6\uff0c\u6216\u8005\u65b0\u5efa\u4e00\u4e2a\u6587\u4ef6\u5e76\u4fdd\u5b58\u4e3a<code>.py<\/code>\u683c\u5f0f\u3002<\/li>\n<li>\u9009\u62e9\u83dc\u5355\u680f\u4e2d\u7684<code>Tools -&gt; Build System -&gt; Python3<\/code>\u3002<\/li>\n<li>\u6309\u4e0b<code>Ctrl + B<\/code>\u5373\u53ef\u8fd0\u884cPython\u4ee3\u7801\uff0c\u8f93\u51fa\u7ed3\u679c\u4f1a\u663e\u793a\u5728Sublime Text\u7684\u8f93\u51fa\u9762\u677f\u4e2d\u3002<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u4f7f\u7528SublimeREPL\u63d2\u4ef6\u8fd0\u884cPython<\/p>\n<\/p>\n<p><p>\u9664\u4e86\u4f7f\u7528\u5185\u7f6e\u7684\u6784\u5efa\u7cfb\u7edf\u5916\uff0c\u8fd8\u53ef\u4ee5\u4f7f\u7528SublimeREPL\u63d2\u4ef6\u6765\u8fd0\u884cPython\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<ol>\n<li>\u6253\u5f00Python\u6587\u4ef6\u3002<\/li>\n<li>\u9009\u62e9\u83dc\u5355\u680f\u4e2d\u7684<code>Tools -&gt; SublimeREPL -&gt; Python -&gt; Python<\/code>\uff0c\u6216\u8005\u6309\u4e0b\u5feb\u6377\u952e<code>Ctrl + Shift + P<\/code>\uff0c\u8f93\u5165<code>SublimeREPL: Python<\/code>\u5e76\u9009\u62e9\u3002<\/li>\n<li>\u5728\u65b0\u6253\u5f00\u7684REPL\u7a97\u53e3\u4e2d\uff0c\u53ef\u4ee5\u76f4\u63a5\u8f93\u5165Python\u4ee3\u7801\u5e76\u8fd0\u884c\u3002<\/li>\n<\/ol>\n<p><p><strong>\u603b\u7ed3<\/strong><\/p>\n<\/p>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u5728Sublime Text\u4e2d\u8f7b\u677e\u8fd0\u884cPython\u4ee3\u7801\u3002<strong>\u5b89\u88c5Package Control\u548cSublimeREPL\u63d2\u4ef6\u3001\u914d\u7f6e\u6784\u5efa\u7cfb\u7edf\u3001\u9009\u62e9\u5408\u9002\u7684Python\u89e3\u91ca\u5668\u662f\u5173\u952e\u6b65\u9aa4\u3002<\/strong>\u8fd9\u4e9b\u64cd\u4f5c\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801\uff0c\u8fd8\u80fd\u63d0\u5347\u6574\u4f53\u7684\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Sublime Text\u4e2d\u8bbe\u7f6ePython\u73af\u5883\uff1f<\/strong><br \/>\u8981\u5728Sublime Text\u4e2d\u8bbe\u7f6ePython\u73af\u5883\uff0c\u60a8\u9700\u8981\u786e\u4fdd\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u5e76\u4e14\u914d\u7f6e\u4e86\u7cfb\u7edf\u8def\u5f84\u3002\u63a5\u7740\uff0c\u6253\u5f00Sublime Text\uff0c\u70b9\u51fb\u83dc\u5355\u680f\u4e2d\u7684\u201cPreferences\u201d\uff0c\u7136\u540e\u9009\u62e9\u201cPackage Control\u201d\u3002\u5728\u641c\u7d22\u6846\u4e2d\u8f93\u5165\u201cAnaconda\u201d\u6216\u201cSublimeREPL\u201d\u5e76\u5b89\u88c5\u76f8\u5e94\u7684\u63d2\u4ef6\u3002\u8fd9\u4e9b\u63d2\u4ef6\u5c06\u4e3a\u60a8\u63d0\u4f9b\u66f4\u597d\u7684\u4ee3\u7801\u8865\u5168\u548c\u8fd0\u884c\u652f\u6301\u3002<\/p>\n<p><strong>\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801\u7684\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801\uff0c\u53ef\u4ee5\u901a\u8fc7\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u6587\u4ef6\uff08.py\uff09\u6765\u5b9e\u73b0\u3002\u8f93\u5165\u60a8\u7684\u4ee3\u7801\u540e\uff0c\u53ef\u4ee5\u4f7f\u7528\u5feb\u6377\u952e<code>Ctrl+B<\/code>\uff08Windows\uff09\u6216<code>Cmd+B<\/code>\uff08Mac\uff09\u8fd0\u884c\u4ee3\u7801\u3002\u786e\u4fdd\u60a8\u7684\u4ee3\u7801\u6ca1\u6709\u8bed\u6cd5\u9519\u8bef\uff0c\u4ee5\u4fbf\u987a\u5229\u6267\u884c\u3002\u540c\u65f6\uff0c\u53ef\u4ee5\u5728\u5e95\u90e8\u7684\u63a7\u5236\u53f0\u7a97\u53e3\u67e5\u770b\u8f93\u51fa\u7ed3\u679c\u3002<\/p>\n<p><strong>\u5982\u4f55\u89e3\u51b3\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u65f6\u51fa\u73b0\u7684\u9519\u8bef\uff1f<\/strong><br \/>\u5982\u679c\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u4ee3\u7801\u65f6\u9047\u5230\u9519\u8bef\uff0c\u9996\u5148\u68c0\u67e5\u60a8\u7684Python\u5b89\u88c5\u662f\u5426\u6b63\u786e\uff0c\u5e76\u786e\u4fdd\u5728Sublime Text\u7684\u6784\u5efa\u7cfb\u7edf\u4e2d\u9009\u62e9\u4e86Python\u3002\u5982\u679c\u4f9d\u7136\u9047\u5230\u95ee\u9898\uff0c\u53ef\u4ee5\u67e5\u770b\u63a7\u5236\u53f0\u8f93\u51fa\uff0c\u67e5\u627e\u5177\u4f53\u7684\u9519\u8bef\u4fe1\u606f\u3002\u786e\u4fdd\u4ee3\u7801\u6ca1\u6709\u8bed\u6cd5\u9519\u8bef\u548c\u903b\u8f91\u9519\u8bef\uff0c\u5e76\u68c0\u67e5\u662f\u5426\u9700\u8981\u5b89\u88c5\u989d\u5916\u7684\u6a21\u5757\u6216\u5e93\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u8981\u5728Sublime Text\u4e2d\u8fd0\u884cPython\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u901a\u8fc7\u5b89\u88c5\u63d2\u4ef6\u3001\u8bbe\u7f6e\u6784\u5efa\u7cfb\u7edf\u7b49\u65b9\u5f0f\u5b9e\u73b0\u3002\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f [&hellip;]","protected":false},"author":3,"featured_media":951269,"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\/951266"}],"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=951266"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/951266\/revisions"}],"predecessor-version":[{"id":951271,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/951266\/revisions\/951271"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/951269"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=951266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=951266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=951266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}