python3.7.3使用web.py报错解决办法 and RuntimeError: generator raised StopIteration

2019/08/13 14:57
阅读数 162

这是想要创建一个用python编写的web项目。但是首先要确定自己的web.py已经安装成功了。

安装的命令是:

pip install web.py==0.40-dev1

运行官网的如下的实例:

import web
urls = (
'/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello: 
def GET(self, name):
if not name: 
name = 'World'
return 'Hello, ' + name + '!'

if __name__ == "__main__":
app.run()

然后出现了如下图所示的错误

Traceback (most recent call last):
File "D:\software\python\lib\site-packages\web\utils.py", line 526, in take
yield next(seq)
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "second.py", line 6, in <module>
app = web.application(urls, globals())
File "D:\software\python\lib\site-packages\web\application.py", line 62, in __init__
self.init_mapping(mapping)
File "D:\software\python\lib\site-packages\web\application.py", line 130, in init_mapping
self.mapping = list(utils.group(mapping, 2))
File "D:\software\python\lib\site-packages\web\utils.py", line 531, in group
x = list(take(seq, size))
RuntimeError: generator raised StopIteration

然后我们就需要进行如下操作

本文参考的是https://blog.csdn.net/gibiguvuggu/article/details/86223332

这位的微博。

 

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部