Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在构建一个 python 脚本,它通过 MySQLdb 库连接到站点的 mysql 数据库。该站点基于 django。我想获取过去 24 小时内登录该站点的用户数,可能使用 django 会话表。我怎样才能只使用 python 和 mysql 来做到这一点?
谢谢
from datetime import datetime, timedelta from django.contrib.auth import User yesterday = datetime.now() - timedelta(days=1) users = User.objects.filter(last_login = yesterday)
没试过这个,但我认为这应该工作