我正在尝试在终端中运行服务器,但返回语法错误,正在使用Django
这是命令响应
File "C:\Program Files\Python37\lib\site-packages\django\__init__.py", line 22
'/' if settings.FORCE_SCRIPT_NAME is not None force_text(settings.FORCE_SCRIPT_NAME)
^
SyntaxError: invalid syntax
'/' if settings.FORCE_SCRIPT_NAME is not None force_text(settings.FORCE_SCRIPT_NAME)
答案 0 :(得分:0)
您忘记了使用else
。
更改此:
'/' if settings.FORCE_SCRIPT_NAME is not None force_text(settings.FORCE_SCRIPT_NAME)
对此:
'/' if settings.FORCE_SCRIPT_NAME is not None else force_text(settings.FORCE_SCRIPT_NAME)