vscode python开发基本配置

2019-12-28  本文已影响0人  Jlan

1. 代码提示

pip安装pylint、flake8、pylint-django
setting.json配置如下:

"python.linting.flake8Enabled": true,
    "python.linting.flake8Args": [
        "--max-line-length=120"
    ],
    "python.linting.pylintArgs": [
        "--load-plugins=pylint_django"
    ]

2. 远程开发和部署

1. Remote - SSH

用来远程连接到服务器,相当于直接把服务器上的文件用本地的vscode打开,直接进行编辑

2. SFTP

自己常用的模式,可以同步代码local-->remote或remote-->local。我一般喜欢在开发本地的项目,修改代码后先同步到remote,然后在remote上测试没问题的话再git提交。

{
    "name": "32",
    "host": "",
    "password": "",
    "protocol": "sftp",
    "port": 3222,
    "username": "bfd",
    "remotePath": "/opt/qa",
    "uploadOnSave": false,
    "syncMode": "update",
    "ignore": [
        "**/.vscode/**",
        "**/.git/**",
        "**/.idea/**"
    ]
}

3. 自动生成注释

可以通过File -> Preferences -> User Snippets创建一个python snippet,内容如下,分别是文件头和函数注释

{
    "HEADER":{
        "prefix": "fileheader",
        "body": [
            "#!/usr/bin/env python",
            "# -*- encoding: utf-8 -*-",
            "'''",
            "@File        :   $TM_FILENAME",
            "@CreateTime  :   $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
            "@Author      :   name ",
            "@Version     :   1.0",
            "@Contact     :   email",
            "@Description :   None",
            
            "'''",
            "",
            "# here put the import lib",
            "$0"
        ]
    },

    "COMMENT":{
        "prefix": "codecomment",
        "body": [
            "'''description",
            "$0",
            "Args:",
            "    param name (param type): describe the param",
            "$0",
            "Returns:",
            "    type: description",
            "'''"
        ],
    },

    // "COMMENT":{
    //     "prefix": "codecomment",
    //     "body": [
    //     "def $1($2):",
    //     "    \"\"\"",
    //     "    param $2:",
    //     "    return:",
    //     "    \"\"\"",
    //     "    $0"
    // ],
    // }
}
上一篇下一篇

猜你喜欢

热点阅读