返回老旧博客

2023 年

这一年写下的旧文。

Python ·

djang 执行linux命令

在 Django 中执行 Linux 命令可以使用 Python 的 subprocess 模块。subprocess 模块允许您在 Python 中执行外部命令,并获取其输出。以下是一个示例代码,演示如何在 Dj...

Python ·

Django获取请求的IP地址

x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR') # 判断是否使用代理 if x_forwarded_for: ip = x_forwarded_...