VSCode-python 进阶配置

VSCode-python 进阶配置

中文乱码

中文乱码,网上一堆解决方法,可是根本没有有效起做用的。
在python脚本的前面添加:python

# -*- coding:utf-8 -*-

并不能在控制台输出时是的print输出中文不乱码。可是此时os.system()的输出倒是正常的,
若是使用调试进行输出获得相反的结果:print输出正常,可是终端输出乱码。json

解决方法:尽可能不要用中文
好吧,确实没卵用!哪位小伙伴有解决方法,请不吝赐教。vim

自动添加文首注释

此时须要安装vscode-fileheader
安装后须要进行相关配置:
文件 ——> 首选项 ——> 设置
打开setting.json,搜索fileheader,找到如下设置:插件

// By default, create file  username
  "fileheader.Author": "mikey.zhaopeng",

  // By default, common template. Do not modify it!!!!!
  "fileheader.tpl": "/*\r\n * @Author: {author} \r\n * @Date: {createTime} \r\n * @Last Modified by:   {lastModifiedBy} \r\n * @Last Modified time: {updateTime} \r\n */\r\n",

  // By default, update file  username.
  "fileheader.LastModifiedBy": "mikey.zhaopeng",

而后进行更改:调试

// By default, create file  username 此处更改成你的用户名
    "fileheader.Author": "Yanta", 

    // By default, common template. Do not modify it!!!!! 
     "fileheader.tpl": "#!/usr/bin/env python \r\n# -*- coding:utf-8 -*- \r\n'''\r\n * @Author: {author} \r\n * @Date: {createTime} \r\n * @Last Modified by:   {lastModifiedBy} \r\n * @Last Modified time: {updateTime} \r\n * @Desc: \r\n'''\r\n",
  
    // By default, update file  username. 此处更改成你的用户名
    "fileheader.LastModifiedBy": "Yanta",
    "workbench.iconTheme": "vscode-icons"

更改过上述配置以后须要重启vscode,不然不会应用更改。
重启后新创建文件,按下快捷键:Ctrl+Alt+i,就会在脚本开头自动填入注释内容。code

不足

file-header目前没法自动添加注释部分,并且没法想vim同样能够自动识别脚本类型,而后自动插入对应的文首注释。
注释只能针对全部的脚本文件一视同仁。utf-8

文件图标

增长文件图标插件,实际上就是为了好看。
直接搜索:vscode-icons安装便可。it

相关文章
相关标签/搜索