【发布时间】:2021-04-13 16:01:53
【问题描述】:
我是 python 新手,我不明白这个正斜杠在 django settings.py 中是如何工作的
STATICFILES_DIRS = [
BASE_DIR / "static",
]
它似乎是连接 BASE_DIR + "static" 的值,但实际上 str(BASE_DIR) + "static" 对吗?
它是某种特殊的 Django 分隔符吗?
根据 Django 文档,这是正确的用法: https://docs.djangoproject.com/en/3.1/howto/static-files/#configuring-static-files
STATICFILES_DIRS 不是参数列表 - 所以这似乎不适用 https://docs.python.org/3/faq/programming.html#what-does-the-slash-in-the-parameter-list-of-a-function-mean
它不是二元除法运算符: https://docs.python.org/3/reference/expressions.html#binary
【问题讨论】: