Python 开发¶ Python 后端开发学习笔记。 基础语法¶ Python1 2 3 4 5 6 7# 变量定义 name = "Python" version = 3.9 # 函数定义 def greet(name): return f"Hello, {name}!" Web 框架¶ Flask¶ Python1 2 3 4 5 6from flask import Flask app = Flask(__name__) @app.route('/') def hello(): return 'Hello, World!' Django¶ Python1 2 3 4 5 6# Django 模型示例 from django.db import models class Article(models.Model): title = models.CharField(max_length=100) content = models.TextField() 数据库操作¶ Python1 2 3 4 5 6 7 8 9import sqlite3 # 连接数据库 conn = sqlite3.connect('example.db') cursor = conn.cursor() # 执行查询 cursor.execute("SELECT * FROM users") results = cursor.fetchall() Python 让后端开发变得简单高效 2025-09-192025-09-19 💬 评论 评论系统加载中...