目录

VS-Code-python设置及jupyter快捷键设置

VS Code python设置及jupyter快捷键设置

VS Code python设置及jupyter快捷键设置

概述

之前一直使用pycharm作为python的IDE,但由于本人不是重度的python使用开发者,并且pycharm Community 不支持jupyter notebook,所以近期改用VS Code来进行python的开发和使用。

python编译环境设置

安装VS Code后,在左下角Manage->setting进入设置界面。

https://i-blog.csdnimg.cn/blog_migrate/9e7c22f9ae7fcd26455349c9fe773230.png

Serch settings 中输入python path,并且在Python>Analysis:Cash Floder Path中输入python的文件夹定位。

https://i-blog.csdnimg.cn/blog_migrate/38da5fce21fde72b2cdbcc6e24e790c2.png

并且选择下方Python>Auto Complete:Extra Paths中选择Edit in setting.josn,并在其中输入如下代码:

    "python.formatting.provider": "yapf",
    "python.linting.flake8Args": ["--max-line-length=248"],
    "python.linting.pylintEnabled": false,
    "jupyter.interactiveWindowMode": "perFile",
    "jupyter.alwaysScrollOnNewCell": true,
    "jupyter.experiments.optInto": ["All"]

具体形式如图所示:

https://i-blog.csdnimg.cn/blog_migrate/bc9f9c2025c5693f337dd28c6bdb6dcd.png

这里我们就完成了python的设置,新建py文件,输入print(“hello,world!”)试试吧!

设置jupyter快捷键

做python开发的都知道jupyter notebook的重要性,所以我们要实现在VS Code对.py文件使用shfit+Enter进行代码编译的方法,需要进行以下设置。

首先找到setting.josn的目录位置。

https://i-blog.csdnimg.cn/blog_migrate/4f8a5896c90a8355df5b540844c30ccd.png

在当前目录下有一个keybindings.josn文件,对当前文件进行编译。

https://i-blog.csdnimg.cn/blog_migrate/ed9ff318b9bc24344f61dd0cbcf099e5.png

输入以下代码:

[
    {
        "key": "shift+enter",
        "command": "jupyter.execSelectionInteractive", 
        "when": "editorTextFocus"
    }
]

设置后保存。这样就完成了对jupyter的快捷键设置了。快去试试Shift+Enter是否管用吧。

https://i-blog.csdnimg.cn/blog_migrate/cdde74371e464cfb2e81248a95109350.png