Web IDE与VS Code
Web IDE就像是"在线版的VS Code",让你在浏览器中就能享受到专业编程编辑器的功能。不需要安装任何软件,打开网页就能开始编程,而且功能几乎和本地VS Code一样强大。
主要功能
编辑器功能
智能编辑:代码有颜色标记,容易阅读,输入时自动提示和补全,智能错误检查和修复,自动格式化代码。
终端集成:内置命令行终端,支持分屏显示,可以运行各种命令,方便管理文件和环境。
扩展支持
预装扩展:Python开发环境,Jupyter Notebook支持,Git版本控制,Docker容器管理,远程开发工具,智能代码提示。
扩展管理:可以安装新的扩展,可以禁用不需要的扩展,扩展功能丰富,提高开发效率。
环境配置
工作区设置
-
基本配置
{
"editor.fontSize": 14,
"editor.tabSize": 4,
"editor.wordWrap": "on",
"files.autoSave": "afterDelay",
"terminal.integrated.fontSize": 14
} -
Python 配置
{
"python.linting.enabled": true,
"python.formatting.provider": "black",
"python.linting.pylintEnabled": true,
"jupyter.notebookFileRoot": "${workspaceFolder}"
}
快捷键设置
-
常用快捷键
keybindings:
editor:
format_document: "Shift + Alt + F"
quick_fix: "Ctrl + ."
go_to_definition: "F12"
find_all_references: "Shift + F12"
terminal:
new_terminal: "Ctrl + `"
split_terminal: "Ctrl + Shift + 5"
notebook:
run_cell: "Shift + Enter"
add_cell: "B"
change_to_markdown: "M" -
自定义快捷键
{
"key": "ctrl+shift+r",
"command": "jupyter.runAllCells",
"when": "editorTextFocus && jupyter.hascodecells"
}
Jupyter 集成
Notebook 支持
-
创建 Notebook
# 通过命令面板
Ctrl/Cmd + Shift + P
> Create New Jupyter Notebook
# 通过文件菜单
File > New File > Jupyter Notebook -
交互式开发
# 在单元格中执行代码
# 选择 Python 内核
import numpy as np
import pandas as pd
# 显示变量
%whos
# 魔法命令
%%time
for i in range(1000000):
pass
调试功能
-
断点调试
# 设置断点
def process_data(data):
# 在这里设置断点
result = complex_calculation(data)
return result
# 启动调试
if __name__ == "__main__":
data = load_data()
result = process_data(data) -
变量检查
# 在调试控制台中
> print(data.shape)
> data.head()
> type(result)
Git 集成
基本操作
-
仓库操作
# 克隆仓库
git clone https://github.com/username/repo.git
# 初始化仓库
git init -
版本控制
# 暂存更改
git add .
# 提交更改
git commit -m "描述更改"
# 推送更改
git push origin main
图形界面
-
源代码管理
- 文件状态查看
- 更改对比
- 提交历史
- 分支管理
-
合并冲突
conflict_resolution:
- 打开冲突文件
- 选择保留更改
- 标记为已解决
- 提交更改
远程开发
SSH连接
配置连接
- 设置远程服务器地址
- 配置用户名和端口
- 设置身份验证文件
- 测试连接是否成功
远程操作
- 连接到远程主机
- 打开远程文件夹
- 在远程环境中开发
- 管理远程文件
容器开发
Docker配置:使用Python 3.9镜像,挂载工作文件夹,设置Python路径,配置开发环境。
容器操作:在容器中打开项目,重建开发容器,管理容器环境,确保环境一致性。
性能优化
编辑器优化
-
性能设置
{
"editor.minimap.enabled": false,
"editor.renderWhitespace": "none",
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true
}
} -
文件处理
{
"files.exclude": {
"**/__pycache__": true,
"**/.pytest_cache": true,
"**/*.pyc": true
}
}