python 拼接url路径时报TypeError: 'URLSpec' object is not iterable?

  1. 访问user_url时时可以访问的, 但是再加上community_url就提示'TypeError: 'URLSpec' object is not iterable'错误.
  2. python 拼接url路径时报TypeError: 'URLSpec' object is not iterable?

这是urlpattern += user_urls.urlpattern输出的

python 拼接url路径时报TypeError: 'URLSpec' object is not iterable?

这是加上urlpattern += community_urls.urlpattern后就报错了.

user_urls和commiunity_urls里是这样的:

from apps.user.handler import LoginHandler, RegisterHanlder, CodeHandler

urlpattern = (

url('/code/', CodeHandler)

url('/login/', LoginHandler)

url('/register/', RegisterHandler)

)

from apps.community.handler import GroupHandler

urlpattern = (

url('/groups/', GroupHandler)

)

启动文件里是这样的:

app = web.Application(urlpattern, debug=True, **settings)


回答:

经过调试我发现community.urls返回的不是tuple类型
原因是我忘记在urlpattern里面忘记加','了

以上是 python 拼接url路径时报TypeError: 'URLSpec' object is not iterable? 的全部内容, 来源链接: utcz.com/a/161646.html

回到顶部