本提示词是一个Python开发任务的通用模板,要求AI作为资深Python开发专家完成指定任务,并明确项目信息、功能需求、代码规范(PEP 8、类型提示、docstring、单元测试等)、技术约束与输出要求,确保代码符合最佳实践且具备生产环境可用性。适用于Web应用、数据分析、机器学习、自动化脚本等各类Python开发场景。

中文版提示词

请你作为一名资深的Python开发专家,帮我完成[具体任务描述]。

项目信息:
- Python版本:[3.8+/3.9+/3.10+等]
- 项目类型:[Web应用/数据分析/机器学习/自动化脚本/API服务等]
- 主要框架:[Django/Flask/FastAPI/无框架等]
- 依赖管理:[pip/poetry/conda等]

功能需求:
1. [核心功能描述]
2. [输入输出要求]
3. [性能指标]
4. [错误处理需求]

代码规范要求:遵循PEP 8编码规范;使用类型提示(Type Hints);包含完整的docstring文档;添加适当的错误处理和日志记录;编写单元测试用例;考虑代码的可读性和可维护性。

技术约束:
- 兼容性要求:[指定Python版本范围]
- 禁用库:[不能使用的第三方库]
- 性能要求:[内存占用/执行时间等限制]

输出要求:
1. 提供完整可运行的Python代码;
2. 包含requirements.txt或pyproject.toml;
3. 添加使用示例和测试代码;
4. 解释关键算法和设计模式;
5. 说明如何部署和运行。

请确保代码遵循Python最佳实践,具备生产环境可用性。

英文版提示词

Please act as a senior Python development expert and help me with [specific task description].

Project information:
- Python version: [3.8+/3.9+/3.10+ etc.]
- Project type: [Web app/Data analysis/Machine learning/Automation script/API service etc.]
- Main framework: [Django/Flask/FastAPI/None etc.]
- Dependency management: [pip/poetry/conda etc.]

Functional requirements:
1. [Core feature description]
2. [Input/output requirements]
3. [Performance metrics]
4. [Error handling requirements]

Code standards: follow PEP 8; use type hints; include complete docstrings; add appropriate error handling and logging; write unit tests; consider readability and maintainability.

Technical constraints:
- Compatibility: [specify Python version range]
- Forbidden libraries: [third-party libraries that cannot be used]
- Performance requirements: [memory usage/execution time limits etc.]

Output requirements:
1. Provide complete, runnable Python code;
2. Include requirements.txt or pyproject.toml;
3. Add usage examples and test code;
4. Explain key algorithms and design patterns;
5. Explain how to deploy and run.

Please ensure the code follows Python best practices and is production-ready.

🛠️ **适用 AI 工具**:Claude、ChatGPT、Cursor、Copilot、DeepSeek、Gemini