首页 > 解决方案 > invalid syntax for unknown reason

问题描述

I'm doing some django stuffs using vs code and this error in the line 3 ("from") happend for no reason.

from django.urls import path
from * import views
urlpatterns = [path(" ",views,name="home")]

标签: python-3.xvisual-studio-code

解决方案


您的第二次导入似乎不正确。

语法应该是:

from <module> import <library / *>

在你的情况下,它应该是:

from views import *

这应该是正确的,只要视图模块确实存在并且可以被python找到。


推荐阅读