python3.7.3使用web.py報錯解決辦法 and RuntimeError: generator raised StopIteration


這是想要創建一個用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

這位的微博。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM