VSCode-python 進階配置
阿新 • • 發佈:2017-12-11
env 安裝 -i temp ctrl .json 作用 python腳本 key
VSCode-python 進階配置
中文亂碼
中文亂碼,網上一堆解決方法,但是根本沒有有效起作用的。
在python腳本的前面添加:
# -*- coding:utf-8 -*-
並不能在控制臺輸出時是的print輸出中文不亂碼。但是此時os.system()的輸出卻是正常的,
如果使用調試進行輸出得到相反的結果:print輸出正常,但是終端輸出亂碼。
解決方法:盡量不要用中文
好吧,確實沒卵用!哪位小夥伴有解決方法,請不吝賜教。
自動添加文首註釋
此時需要安裝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,就會在腳本開頭自動填入註釋內容。
不足
file-header目前無法自動添加註釋部分,而且無法想vim一樣可以自動識別腳本類型,然後自動插入對應的文首註釋。
註釋只能針對所有的腳本文件一視同仁。
文件圖標
增加文件圖標插件,實際上就是為了好看。
直接搜索:vscode-icons安裝即可。
VSCode-python 進階配置