{"id":964190,"date":"2024-12-27T04:25:57","date_gmt":"2024-12-26T20:25:57","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/964190.html"},"modified":"2024-12-27T04:25:59","modified_gmt":"2024-12-26T20:25:59","slug":"%e5%a6%82%e4%bd%95%e7%94%a8vi%e7%bc%96%e5%86%99python","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/964190.html","title":{"rendered":"\u5982\u4f55\u7528vi\u7f16\u5199python"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/24181123\/0eff1343-8908-4ed0-b5bb-9806ff235d96.webp\" alt=\"\u5982\u4f55\u7528vi\u7f16\u5199python\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528Vi\u7f16\u5199Python\u4ee3\u7801\u7684\u6838\u5fc3\u5728\u4e8e\uff1a\u638c\u63e1\u57fa\u672c\u7684Vi\u547d\u4ee4\u3001\u8bbe\u7f6e\u597dVi\u7684Python\u7f16\u8f91\u73af\u5883\u3001\u5229\u7528Vi\u63d2\u4ef6\u63d0\u9ad8\u6548\u7387<\/strong>\u3002\u5176\u4e2d\uff0c\u5b66\u4e60\u57fa\u672c\u547d\u4ee4\u662f\u521d\u5b66\u8005\u7684\u7b2c\u4e00\u6b65\uff0c<strong>\u800c\u8bbe\u7f6e\u7f16\u8f91\u73af\u5883\u548c\u63d2\u4ef6\u4f7f\u7528\u5219\u5927\u5927\u63d0\u5347\u4e86\u7f16\u5199Python\u4ee3\u7801\u7684\u8212\u9002\u6027\u548c\u6548\u7387<\/strong>\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u5229\u7528Vi\u7f16\u5199Python\u4ee3\u7801\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001VI\u7f16\u8f91\u5668\u7684\u57fa\u672c\u547d\u4ee4<\/p>\n<\/p>\n<p><p>Vi\u7f16\u8f91\u5668\u662fUnix\u548cLinux\u7cfb\u7edf\u4e0a\u7684\u7ecf\u5178\u6587\u672c\u7f16\u8f91\u5668\u3002\u8981\u719f\u7ec3\u4f7f\u7528Vi\u7f16\u8f91Python\u4ee3\u7801\uff0c\u9996\u5148\u9700\u8981\u638c\u63e1\u4e00\u4e9b\u57fa\u672c\u547d\u4ee4\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f<\/strong><\/p>\n<\/p>\n<p><p>\u5728Vi\u4e2d\uff0c\u9ed8\u8ba4\u662f\u547d\u4ee4\u6a21\u5f0f\u3002\u8981\u8f93\u5165\u6587\u672c\uff0c\u9996\u5148\u9700\u8981\u5207\u6362\u5230\u63d2\u5165\u6a21\u5f0f\u3002\u5e38\u7528\u7684\u547d\u4ee4\u6709\uff1a<\/p>\n<\/p>\n<ul>\n<li><code>i<\/code>\uff1a\u5728\u5149\u6807\u524d\u63d2\u5165\u3002<\/li>\n<li><code>a<\/code>\uff1a\u5728\u5149\u6807\u540e\u63d2\u5165\u3002<\/li>\n<li><code>o<\/code>\uff1a\u5728\u5f53\u524d\u884c\u4e0b\u65b9\u65b0\u5efa\u4e00\u884c\u5e76\u8fdb\u5165\u63d2\u5165\u6a21\u5f0f\u3002<\/li>\n<\/ul>\n<p><p>\u4e00\u65e6\u5b8c\u6210\u7f16\u8f91\uff0c\u53ef\u4ee5\u6309<code>Esc<\/code>\u952e\u8fd4\u56de\u5230\u547d\u4ee4\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4fdd\u5b58\u548c\u9000\u51fa<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\uff0c\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4fdd\u5b58\u6216\u9000\u51fa\uff1a<\/p>\n<\/p>\n<ul>\n<li><code>:w<\/code>\uff1a\u4fdd\u5b58\u6587\u4ef6\u3002<\/li>\n<li><code>:q<\/code>\uff1a\u9000\u51faVi\u3002<\/li>\n<li><code>:wq<\/code>\uff1a\u4fdd\u5b58\u5e76\u9000\u51fa\u3002<\/li>\n<li><code>:q!<\/code>\uff1a\u5f3a\u5236\u9000\u51fa\u4e0d\u4fdd\u5b58\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5bfc\u822a\u548c\u7f16\u8f91<\/strong><\/p>\n<\/p>\n<p><p>Vi\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5bfc\u822a\u548c\u7f16\u8f91\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<ul>\n<li><code>h<\/code>, <code>j<\/code>, <code>k<\/code>, <code>l<\/code>\uff1a\u5206\u522b\u5411\u5de6\u3001\u4e0b\u3001\u4e0a\u3001\u53f3\u79fb\u52a8\u5149\u6807\u3002<\/li>\n<li><code>x<\/code>\uff1a\u5220\u9664\u5149\u6807\u6240\u5728\u5b57\u7b26\u3002<\/li>\n<li><code>dd<\/code>\uff1a\u5220\u9664\u6574\u884c\u3002<\/li>\n<li><code>yy<\/code>\uff1a\u590d\u5236\u6574\u884c\u3002<\/li>\n<li><code>p<\/code>\uff1a\u7c98\u8d34\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><p><strong>\u638c\u63e1\u8fd9\u4e9b\u57fa\u672c\u547d\u4ee4\u540e\uff0c\u7528\u6237\u4fbf\u53ef\u4ee5\u5728Vi\u4e2d\u8fdb\u884c\u7b80\u5355\u7684\u6587\u672c\u7f16\u8f91\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e8c\u3001\u914d\u7f6eVI\u4ee5\u9002\u5e94Python\u5f00\u53d1<\/p>\n<\/p>\n<p><p>\u5728\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cVi\u5e76\u6ca1\u6709\u7279\u522b\u9488\u5bf9Python\u4f18\u5316\u3002\u901a\u8fc7\u4e00\u4e9b\u914d\u7f6e\uff0c\u53ef\u4ee5\u4f7fVi\u66f4\u9002\u5408Python\u5f00\u53d1\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u81ea\u52a8\u7f29\u8fdb<\/strong><\/p>\n<\/p>\n<p><p>Python\u5bf9\u7f29\u8fdb\u8981\u6c42\u4e25\u683c\uff0c\u56e0\u6b64\u786e\u4fddVi\u80fd\u591f\u81ea\u52a8\u7f29\u8fdb\u662f\u975e\u5e38\u91cd\u8981\u7684\u3002\u5728<code>~\/.vimrc<\/code>\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u914d\u7f6e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">set tabstop=4       &quot; \u8bbe\u7f6e\u4e00\u4e2atab\u4e3a4\u4e2a\u7a7a\u683c<\/p>\n<p>set shiftwidth=4    &quot; \u6bcf\u6b21\u7f29\u8fdb\u4e3a4\u4e2a\u7a7a\u683c<\/p>\n<p>set expandtab       &quot; \u5c06tab\u8f6c\u6362\u4e3a\u7a7a\u683c<\/p>\n<p>set autoindent      &quot; \u81ea\u52a8\u7f29\u8fdb<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bed\u6cd5\u9ad8\u4eae<\/strong><\/p>\n<\/p>\n<p><p>\u8bed\u6cd5\u9ad8\u4eae\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u66f4\u5bb9\u6613\u5730\u9605\u8bfb\u4ee3\u7801\u3002\u5728<code>~\/.vimrc<\/code>\u4e2d\u542f\u7528\u8bed\u6cd5\u9ad8\u4eae\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">syntax on<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u663e\u793a\u884c\u53f7<\/strong><\/p>\n<\/p>\n<p><p>\u884c\u53f7\u5bf9\u4e8e\u8c03\u8bd5\u548c\u4ee3\u7801\u5bfc\u822a\u975e\u5e38\u6709\u7528\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">set number<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ol>\n<p><p><strong>\u901a\u8fc7\u8fd9\u4e9b\u7b80\u5355\u7684\u914d\u7f6e\uff0cVi\u53ef\u4ee5\u663e\u8457\u63d0\u9ad8Python\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u5f00\u53d1\u6548\u7387\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e09\u3001\u5229\u7528VI\u63d2\u4ef6\u63d0\u9ad8\u6548\u7387<\/p>\n<\/p>\n<p><p>Vi\u62e5\u6709\u4e30\u5bcc\u7684\u63d2\u4ef6\u751f\u6001\uff0c\u901a\u8fc7\u5b89\u88c5\u63d2\u4ef6\u53ef\u4ee5\u5927\u5927\u63d0\u5347Python\u5f00\u53d1\u7684\u6548\u7387\u548c\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u63d2\u4ef6\u7ba1\u7406\u5668<\/strong><\/p>\n<\/p>\n<p><p>\u8981\u4f7f\u7528\u63d2\u4ef6\uff0c\u9996\u5148\u9700\u8981\u4e00\u4e2a\u63d2\u4ef6\u7ba1\u7406\u5668\u3002<code>Vundle<\/code>\u662f\u4e00\u4e2a\u5e38\u7528\u7684\u63d2\u4ef6\u7ba1\u7406\u5668\u3002\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">git clone https:\/\/github.com\/VundleVim\/Vundle.vim.git ~\/.vim\/bundle\/Vundle.vim<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728<code>~\/.vimrc<\/code>\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">set nocompatible              &quot; \u53bb\u6389\u4e0evi\u517c\u5bb9\u6a21\u5f0f<\/p>\n<p>filetype off                  &quot; \u5fc5\u987b<\/p>\n<p>set rtp+=~\/.vim\/bundle\/Vundle.vim<\/p>\n<p>call vundle#begin()<\/p>\n<p>&quot; \u5728\u8fd9\u4e24\u884c\u4e4b\u95f4\u5b89\u88c5\u63d2\u4ef6<\/p>\n<p>Plugin &#39;VundleVim\/Vundle.vim&#39;<\/p>\n<p>call vundle#end()            &quot; \u5fc5\u987b<\/p>\n<p>filetype plugin indent on    &quot; \u5fc5\u987b<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5e38\u7528Python\u63d2\u4ef6<\/strong><\/p>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684Python\u5f00\u53d1\u63d2\u4ef6\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p><strong><code>vim-python-pep8-indent<\/code><\/strong>\uff1a\u81ea\u52a8\u7f29\u8fdb\u7b26\u5408PEP8\u6807\u51c6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">Plugin &#39;Vimjas\/vim-python-pep8-indent&#39;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong><code>syntastic<\/code><\/strong>\uff1a\u8bed\u6cd5\u68c0\u67e5\u5de5\u5177\uff0c\u652f\u6301Python\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">Plugin &#39;vim-syntastic\/syntastic&#39;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong><code>YouCompleteMe<\/code><\/strong>\uff1a\u4ee3\u7801\u8865\u5168\u63d2\u4ef6\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-vim\">Plugin &#39;ycm-core\/YouCompleteMe&#39;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<p><p>\u5b89\u88c5\u63d2\u4ef6\u540e\uff0c\u8fdb\u5165Vi\u5e76\u6267\u884c<code>:PluginInstall<\/code>\u547d\u4ee4\u5b89\u88c5\u63d2\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p><strong>\u901a\u8fc7\u63d2\u4ef6\u7684\u4f7f\u7528\uff0cVi\u53ef\u4ee5\u4ece\u4e00\u4e2a\u7b80\u5355\u7684\u6587\u672c\u7f16\u8f91\u5668\u8f6c\u53d8\u4e3a\u529f\u80fd\u5f3a\u5927\u7684Python IDE\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u56db\u3001\u4f7f\u7528VI\u8fdb\u884cPython\u7f16\u7801\u7684\u6700\u4f73\u5b9e\u8df5<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Vi\u8fdb\u884cPython\u5f00\u53d1\u65f6\uff0c\u9075\u5faa\u4e00\u4e9b\u6700\u4f73\u5b9e\u8df5\u53ef\u4ee5\u63d0\u5347\u4ee3\u7801\u8d28\u91cf\u548c\u5f00\u53d1\u6548\u7387\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u9075\u5faaPEP8\u6807\u51c6<\/strong><\/p>\n<\/p>\n<p><p>PEP8\u662fPython\u7684\u7f16\u7801\u98ce\u683c\u6307\u5357\uff0c\u9075\u5faa\u8fd9\u4e9b\u6807\u51c6\u53ef\u4ee5\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u4e00\u81f4\u6027\u3002\u5728Vi\u4e2d\u4f7f\u7528<code>vim-python-pep8-indent<\/code>\u63d2\u4ef6\u53ef\u4ee5\u81ea\u52a8\u5e2e\u52a9\u683c\u5f0f\u5316\u4ee3\u7801\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9891\u7e41\u4fdd\u5b58\u548c\u5907\u4efd<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>:w<\/code>\u547d\u4ee4\u9891\u7e41\u4fdd\u5b58\u4ee3\u7801\uff0c\u907f\u514d\u56e0\u610f\u5916\u5173\u95ed\u6216\u7cfb\u7edf\u6545\u969c\u5bfc\u81f4\u4ee3\u7801\u4e22\u5931\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528\u7248\u672c\u63a7\u5236\u7cfb\u7edf\u5982Git\u8fdb\u884c\u4ee3\u7801\u7ba1\u7406\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5229\u7528\u5206\u5c4f\u548c\u6807\u7b7e<\/strong><\/p>\n<\/p>\n<p><p>Vi\u652f\u6301\u5206\u5c4f\u548c\u6807\u7b7e\u529f\u80fd\uff0c\u53ef\u4ee5\u540c\u65f6\u7f16\u8f91\u591a\u4e2a\u6587\u4ef6\u3002\u5728\u547d\u4ee4\u6a21\u5f0f\u4e0b\u4f7f\u7528<code>Ctrl-w<\/code>\u547d\u4ee4\u53ef\u4ee5\u5728\u4e0d\u540c\u7a97\u53e3\u95f4\u5207\u6362\uff0c\u4f7f\u7528<code>:tabnew<\/code>\u53ef\u4ee5\u6253\u5f00\u65b0\u6807\u7b7e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8c03\u8bd5\u548c\u6d4b\u8bd5<\/strong><\/p>\n<\/p>\n<p><p>\u5728Vi\u4e2d\u53ef\u4ee5\u901a\u8fc7\u5916\u90e8\u7ec8\u7aef\u8fd0\u884cPython\u4ee3\u7801\u8fdb\u884c\u8c03\u8bd5\u3002\u53ef\u4ee5\u5728Vi\u4e2d\u4f7f\u7528<code>:!python %<\/code>\u547d\u4ee4\u6765\u8fd0\u884c\u5f53\u524d\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p><strong>\u901a\u8fc7\u9075\u5faa\u8fd9\u4e9b\u6700\u4f73\u5b9e\u8df5\uff0c\u53ef\u4ee5\u63d0\u9ad8Python\u5f00\u53d1\u7684\u6548\u7387\u548c\u4ee3\u7801\u7684\u8d28\u91cf\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u4e94\u3001\u89e3\u51b3\u5e38\u89c1\u95ee\u9898<\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528Vi\u8fdb\u884cPython\u5f00\u53d1\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e9b\u89e3\u51b3\u65b9\u6848\u3002<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f29\u8fdb\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u53d1\u73b0\u7f29\u8fdb\u4e0d\u7b26\u5408\u9884\u671f\uff0c\u68c0\u67e5<code>~\/.vimrc<\/code>\u4e2d\u7684\u7f29\u8fdb\u8bbe\u7f6e\uff0c\u786e\u4fdd<code>expandtab<\/code>\u548c<code>shiftwidth<\/code>\u8bbe\u7f6e\u6b63\u786e\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u63d2\u4ef6\u65e0\u6cd5\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u786e\u4fdd\u63d2\u4ef6\u7ba1\u7406\u5668<code>Vundle<\/code>\u6b63\u786e\u5b89\u88c5\uff0c\u5e76\u5728<code>~\/.vimrc<\/code>\u4e2d\u6b63\u786e\u914d\u7f6e\u3002\u5982\u679c\u95ee\u9898\u4f9d\u7136\u5b58\u5728\uff0c\u5c1d\u8bd5\u624b\u52a8\u514b\u9686\u63d2\u4ef6\u5230<code>~\/.vim\/bundle<\/code>\u76ee\u5f55\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u8bed\u6cd5\u9ad8\u4eae\u5931\u6548<\/strong><\/p>\n<\/p>\n<p><p>\u68c0\u67e5<code>~\/.vimrc<\/code>\u4e2d\u662f\u5426\u542f\u7528\u4e86<code>syntax on<\/code>\u3002\u6b64\u5916\uff0c\u786e\u8ba4\u5f53\u524d\u6587\u4ef6\u7684\u6269\u5c55\u540d\u4e3a<code>.py<\/code>\uff0c\u4ee5\u786e\u4fddVi\u8bc6\u522b\u4e3aPython\u6587\u4ef6\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6027\u80fd\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679cVi\u5728\u52a0\u8f7d\u5927\u6587\u4ef6\u6216\u542f\u52a8\u65f6\u53d8\u6162\uff0c\u68c0\u67e5\u662f\u5426\u542f\u7528\u4e86\u8fc7\u591a\u7684\u63d2\u4ef6\u6216\u4e0d\u5fc5\u8981\u7684\u529f\u80fd\u3002\u53ef\u4ee5\u901a\u8fc7\u7981\u7528\u4e00\u4e9b\u4e0d\u5e38\u7528\u7684\u63d2\u4ef6\u6765\u63d0\u9ad8\u6027\u80fd\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p><strong>\u901a\u8fc7\u89e3\u51b3\u8fd9\u4e9b\u5e38\u89c1\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7fVi\u5728Python\u5f00\u53d1\u4e2d\u66f4\u52a0\u7a33\u5b9a\u548c\u9ad8\u6548\u3002<\/strong><\/p>\n<\/p>\n<p><p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u4f7f\u7528Vi\u7f16\u5199Python\u4ee3\u7801\u662f\u4e00\u4e2a\u9ad8\u6548\u4e14\u7075\u6d3b\u7684\u9009\u62e9\u3002\u901a\u8fc7\u638c\u63e1\u57fa\u672c\u547d\u4ee4\u3001\u914d\u7f6e\u7f16\u8f91\u73af\u5883\u3001\u5229\u7528\u63d2\u4ef6\u548c\u9075\u5faa\u6700\u4f73\u5b9e\u8df5\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u5347\u5f00\u53d1\u6548\u7387\u548c\u4ee3\u7801\u8d28\u91cf\u3002\u5728\u9047\u5230\u95ee\u9898\u65f6\uff0c\u901a\u8fc7\u89e3\u51b3\u5e38\u89c1\u95ee\u9898\u7684\u65b9\u6cd5\u53ef\u4ee5\u4fdd\u8bc1Vi\u7684\u7a33\u5b9a\u8fd0\u884c\u3002\u5e0c\u671b\u901a\u8fc7\u8fd9\u7bc7\u6587\u7ae0\uff0c\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u5229\u7528Vi\u8fdb\u884cPython\u5f00\u53d1\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u4f7f\u7528vi\u7f16\u8f91\u5668\u7f16\u5199Python\u4ee3\u7801\u7684\u57fa\u672c\u6b65\u9aa4\u662f\u4ec0\u4e48\uff1f<\/strong><br \/>\u5728vi\u7f16\u8f91\u5668\u4e2d\u7f16\u5199Python\u4ee3\u7801\u7684\u6b65\u9aa4\u76f8\u5bf9\u7b80\u5355\u3002\u9996\u5148\uff0c\u6253\u5f00\u7ec8\u7aef\u5e76\u8f93\u5165<code>vi filename.py<\/code>\uff0c\u5176\u4e2d<code>filename.py<\/code>\u662f\u4f60\u60f3\u8981\u521b\u5efa\u6216\u7f16\u8f91\u7684\u6587\u4ef6\u540d\u3002\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u6309\u4e0b<code>i<\/code>\u952e\u6765\u5f00\u59cb\u8f93\u5165\u4ee3\u7801\u3002\u5b8c\u6210\u540e\uff0c\u6309<code>Esc<\/code>\u952e\u9000\u51fa\u7f16\u8f91\u6a21\u5f0f\uff0c\u8f93\u5165<code>:wq<\/code>\u4fdd\u5b58\u5e76\u9000\u51favi\u7f16\u8f91\u5668\u3002\u8fd9\u6837\u5c31\u53ef\u4ee5\u6210\u529f\u521b\u5efa\u6216\u7f16\u8f91Python\u6587\u4ef6\u3002<\/p>\n<p><strong>\u5728vi\u4e2d\u5982\u4f55\u9ad8\u6548\u5730\u7f16\u8f91Python\u4ee3\u7801\uff1f<\/strong><br \/>\u8981\u9ad8\u6548\u5730\u5728vi\u4e2d\u7f16\u8f91Python\u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e9b\u5feb\u6377\u952e\u548c\u547d\u4ee4\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<code>dd<\/code>\u5220\u9664\u4e00\u884c\uff0c<code>yy<\/code>\u590d\u5236\u4e00\u884c\uff0c<code>p<\/code>\u7c98\u8d34\u3002\u8fd8\u53ef\u4ee5\u5229\u7528<code>\/<\/code>\u8fdb\u884c\u641c\u7d22\uff0c\u5feb\u901f\u5b9a\u4f4d\u5230\u7279\u5b9a\u7684\u4ee3\u7801\u884c\u3002\u5bf9\u4e8ePython\u7684\u7f29\u8fdb\uff0c\u786e\u4fdd\u4f7f\u7528\u7a7a\u683c\u800c\u975e\u5236\u8868\u7b26\uff0c\u4ee5\u7b26\u5408Python\u7684\u8bed\u6cd5\u8981\u6c42\u3002\u901a\u8fc7\u8fd9\u4e9b\u6280\u5de7\uff0c\u53ef\u4ee5\u5927\u5927\u63d0\u9ad8\u4ee3\u7801\u7f16\u5199\u7684\u6548\u7387\u3002<\/p>\n<p><strong>\u4f7f\u7528vi\u7f16\u5199Python\u65f6\uff0c\u5982\u4f55\u8c03\u8bd5\u548c\u8fd0\u884c\u4ee3\u7801\uff1f<\/strong><br \/>\u5728vi\u4e2d\u7f16\u8f91\u5b8cPython\u4ee3\u7801\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u7ec8\u7aef\u8fd0\u884c\u4ee3\u7801\u3002\u53ea\u9700\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python filename.py<\/code>\uff08\u786e\u4fdd\u4f7f\u7528\u6b63\u786e\u7684Python\u7248\u672c\uff09\uff0c\u5373\u53ef\u6267\u884c\u4ee3\u7801\u3002\u5982\u679c\u6709\u9519\u8bef\uff0c\u53ef\u4ee5\u8fd4\u56devi\uff0c\u8fdb\u884c\u4fee\u6539\u3002\u4e3a\u4e86\u65b9\u4fbf\u8c03\u8bd5\uff0c\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u52a0\u5165<code>print<\/code>\u8bed\u53e5\uff0c\u5e2e\u52a9\u5b9a\u4f4d\u95ee\u9898\u3002\u5efa\u8bae\u4f7f\u7528Python\u7684\u5f02\u5e38\u5904\u7406\u673a\u5236\u6765\u6355\u83b7\u9519\u8bef\uff0c\u63d0\u5347\u4ee3\u7801\u7684\u5065\u58ee\u6027\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528Vi\u7f16\u5199Python\u4ee3\u7801\u7684\u6838\u5fc3\u5728\u4e8e\uff1a\u638c\u63e1\u57fa\u672c\u7684Vi\u547d\u4ee4\u3001\u8bbe\u7f6e\u597dVi\u7684Python\u7f16\u8f91\u73af\u5883\u3001\u5229\u7528Vi\u63d2\u4ef6\u63d0\u9ad8 [&hellip;]","protected":false},"author":3,"featured_media":964198,"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\/964190"}],"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=964190"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/964190\/revisions"}],"predecessor-version":[{"id":964202,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/964190\/revisions\/964202"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/964198"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=964190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=964190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=964190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}