vscode2017最佳实战-python-更新20171024,-python-20171024
分享于 点击 47379 次 点评:177
vscode2017最佳实战-python-更新20171024,-python-20171024
我一直用pycharm,但是启动太慢了.转向vs. 这个东西刚开始用不太适应,我顺便总结下点东西
pycharm terminal设置
File -> Settings -> Tools -> Terminal
for 64bit:
"C:\Program Files\Git\bin\sh.exe" -login -i
for 32bit:
"C:\Program Files (x86)\Git\bin\sh.exe" -login -i
"C:\Windows\System32\cmd.exe" /C "bash"
参考
初始化安装软件
pip install virtualenv
pip install virtualenvwrapper
pip install virtualenvwrapper-win
mkvirtualenv --python=C:\Python27\python.exe py27env
exit
mkvirtualenv --python=C:\Python36\python.exe py36env
workon #查看刚刚创建的环境,mkvirtualenv -h查看帮助
vscode安装python插件
设置vscode
文件–首选项–设置
{
"workbench.colorTheme": "Solarized Light",
"window.zoomLevel": 1,
"window.menuBarVisibility": "default",
"editor.wordWrap": "on",
"editor.fontSize": 16,
"files.autoSave": "afterDelay",
"editor.rulers": [80,120],
"python.pythonPath": "C:\\Users\\Administrator\\Envs\\py27env\\Scripts\\python.exe"
}
vscode打开一个目录,写代码
新建demo.py,写个代码然后f5运行试试。会自动创建.vscode目录
.vscode里手动创建1个文件
- tasks.json
{
"version": "0.1.0",
"command": "C:\\Users\\Administrator\\Envs\\py27env\\Scripts\\python.exe",
"isShellCommand": true,
"args": ["${file}"],
"showOutput": "always"
}
至此,ctrl+shit+b可以正常运行python了。
运行django
- launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Python",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
},
{
"name": "Python Console App",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${file}",
"externalConsole": true,
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit"
]
},
{
"name": "Django",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${workspaceRoot}/manage.py",
"args": [
"runserver",
"--noreload"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput",
"DjangoDebugging"
]
},
{
"name": "Watson",
"type": "python",
"request": "launch",
"stopOnEntry": true,
"program": "${workspaceRoot}/console.py",
"args": [
"dev",
"runserver",
"--noreload=True"
],
"debugOptions": [
"WaitOnAbnormalExit",
"WaitOnNormalExit",
"RedirectOutput"
]
}
]
}
安装vs插件
- 快捷键插件: Sublime Text Keymap
- ctrl+shift+d 复制一行
- ctrl+shift + 上下箭头移动一行
- markdown all in one && markdown转pdf
其他比较常用的快键键
Alt+Shift+F # 自动格式化代码 autopep8
Ctrl+Shift+P # 执行命令,如python help
ctrl+p #文件名快速打开
重点参考
记得每次安装插件的时候,看下他的使用说明.
https://code.visualstudio.com/docs/getstarted/tips-and-tricks
https://code.visualstudio.com/docs/languages/python#_install-python-extension
django怎么用我还没弄清楚.
相关文章
- 暂无相关文章
用户点评