Commit c1dfb1ed authored by xiezhi's avatar xiezhi

Initial commit

parents
{
"name": "Python Development Environment",
"image": "hb.eazytec-cloud.com/eazytec/eazydevelop-base:ubuntu",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11",
"installTools": true,
"installPipx": true,
"installPipxGlobalPackages": [
"black",
"flake8",
"mypy",
"pytest"
]
},
"ghcr.io/devcontainers/features/common-utils:2": {
"installZsh": true,
"configureZshAsDefaultShell": true,
"installOhMyZsh": true,
"upgradePackages": true
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.black-formatter",
"ms-python.flake8",
"ms-python.mypy-type-checker",
"ms-python.pylint",
"ms-python.pytest-adapter",
"ms-python.vscode-pylance"
],
"settings": {
"python.defaultInterpreterPath": "/usr/local/bin/python",
"python.linting.enabled": true,
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,
"python.formatting.provider": "black",
"python.testing.pytestEnabled": true,
"python.testing.unittestEnabled": false,
"python.testing.nosetestsEnabled": false
}
}
},
"postCreateCommand": "python --version && pip --version && python /workspaces/python/hello.py",
"remoteUser": "vscode"
}
# 依赖目录
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
target/
# 运行时数据
pids
*.pid
*.seed
*.pid.lock
# 覆盖率目录
lib-cov
coverage/
*.lcov
# nyc 测试覆盖率
.nyc_output
# Grunt 中间存储
.grunt
# Bower 依赖目录
bower_components
# node-waf 配置
.lock-wscript
# 编译后的二进制文件
build/Release
# 依赖目录
jspm_packages/
# TypeScript 缓存
*.tsbuildinfo
# 可选的 npm 缓存目录
.npm
# 可选的 eslint 缓存
.eslintcache
# 微包
.pnp.*
# 测试覆盖率
coverage/
*.lcov
# 生产构建文件
dist/
build/
# 环境变量文件
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# 日志文件
logs
*.log
# 运行时数据
pids
*.pid
*.seed
*.pid.lock
# 目录用于存放 npm 包
.npm
# 目录用于存放可选的 REPL 历史
.node_repl_history
# 输出目录
out/
dist/
# 临时文件夹
tmp/
temp/
# 编辑器目录和文件
.vscode/
.idea/
*.swp
*.swo
*~
# OS 生成的文件
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# 缓存目录
.cache/
.parcel-cache/
# 本地配置文件
*.local
# 数据库文件
*.db
*.sqlite
# 压缩文件
*.zip
*.tar.gz
*.rar
# 备份文件
*.bak
*.backup
# 临时文件
*.tmp
*.temp
# 系统文件
Thumbs.db
ehthumbs.db
Desktop.ini
# 日志文件
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# 运行时数据
pids
*.pid
*.seed
*.pid.lock
# 覆盖率目录
lib-cov
coverage/
*.lcov
# nyc 测试覆盖率
.nyc_output
# Grunt 中间存储
.grunt
# Bower 依赖目录
bower_components
# node-waf 配置
.lock-wscript
# 编译后的二进制文件
build/Release
# 依赖目录
jspm_packages/
# TypeScript 缓存
*.tsbuildinfo
# 可选的 npm 缓存目录
.npm
# 可选的 eslint 缓存
.eslintcache
# 微包
.pnp.*
# 测试覆盖率
coverage/
*.lcov
# 生产构建文件
dist/
build/
# 环境变量文件
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
# 日志文件
logs
*.log
# 运行时数据
pids
*.pid
*.seed
*.pid.lock
# 目录用于存放 npm 包
.npm
# 目录用于存放可选的 REPL 历史
.node_repl_history
# 输出目录
out/
dist/
# 临时文件夹
tmp/
temp/
# 编辑器目录和文件
.vscode/
.idea/
*.swp
*.swo
*~
# OS 生成的文件
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db
# 缓存目录
.cache/
.parcel-cache/
# 本地配置文件
*.local
# 数据库文件
*.db
*.sqlite
# 压缩文件
*.zip
*.tar.gz
*.rar
# 备份文件
*.bak
*.backup
# 临时文件
*.tmp
*.temp
# 系统文件
Thumbs.db
ehthumbs.db
Desktop.ini
# Python开发环境
这是一个基于Dev Container的Python开发环境配置。
## 特性
- **Python 3.11**: 最新的稳定版本
- **代码质量工具**:
- Black (代码格式化)
- Flake8 (代码检查)
- MyPy (类型检查)
- Pylint (代码分析)
- **测试框架**: Pytest
- **开发工具**: IPython, Jupyter
- **Shell环境**: Zsh + Oh My Zsh
## 使用方法
1. 在VS Code中打开此项目
2. 当提示时,选择"在容器中重新打开"
3. 等待容器构建完成
4. 运行 `hello.py` 文件查看Hello World示例
## 运行Hello World
```bash
python hello.py
```
## 安装依赖
```bash
pip install -r requirements.txt
```
## 代码格式化
```bash
black .
```
## 代码检查
```bash
flake8 .
mypy .
pylint .
```
## 运行测试
```bash
pytest
```
## 文件结构
```
.
├── .devcontainer/
│ └── devcontainer.json # Dev Container配置
├── hello.py # Hello World示例程序
├── requirements.txt # Python依赖
└── README.md # 项目说明
```
## 扩展功能
这个环境包含了以下VS Code扩展:
- Python语言支持
- Python调试器
- 代码格式化
- 代码检查
- 类型检查
- 测试支持
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
简单的Hello World程序
演示基本的Python语法和输出
"""
def main():
"""
主函数:打印Hello World消息
"""
print("Hello, World! 你好,世界!")
print("欢迎使用Python开发环境!")
# 演示一些基本的Python特性
name = "Python开发者"
version = 3.11
print(f"你好,{name}!你正在使用Python {version}")
# 简单的数学运算
numbers = [1, 2, 3, 4, 5]
total = sum(numbers)
print(f"数字列表 {numbers} 的总和是: {total}")
if __name__ == "__main__":
main()
# Python开发环境依赖包
# 代码质量工具
black==23.12.1
flake8==7.0.0
mypy==1.8.0
pylint==3.0.3
# 测试框架
pytest==7.4.4
pytest-cov==4.1.0
# 开发工具
ipython==8.18.1
jupyter==1.0.0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment