小编n8t*_*ael的帖子

正斜杠在此 django settings.py python 列表中起什么作用?

我是 python 新手,我不明白这个正斜杠在 django settings.py 中是如何工作的

STATICFILES_DIRS = [
    BASE_DIR / "static",
]
Run Code Online (Sandbox Code Playgroud)

看起来它是连接 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 -函数均值

它不是二元除法运算符: https ://docs.python.org/3/reference/expressions.html#binary

python django

7
推荐指数
1
解决办法
611
查看次数

标签 统计

django ×1

python ×1