测试文件报错

来源:1-4 web.py测试

慕九州008247

2018-09-27 15:47

E:\pycharmProject\venv\Scripts\python.exe E:/pycharmProject/hello.py

Traceback (most recent call last):

  File "E:\pycharmProject\venv\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 "E:/pycharmProject/hello.py", line 6, in <module>

    app = web.application(urls, globals())

  File "E:\pycharmProject\venv\lib\site-packages\web\application.py", line 62, in __init__

    self.init_mapping(mapping)

  File "E:\pycharmProject\venv\lib\site-packages\web\application.py", line 130, in init_mapping

    self.mapping = list(utils.group(mapping, 2))

  File "E:\pycharmProject\venv\lib\site-packages\web\utils.py", line 531, in group

    x = list(take(seq, size))

RuntimeError: generator raised StopIteration


写回答 关注

3回答

  • qq289此生有你
    2019-04-16 11:37:59

    https://img.mukewang.com/5cb54e0a0001171308860262.jpg改成这样就好了

  • 念奴娇
    2019-03-01 11:28:01

    错误原因,python3以上安装执行应pip install web.py==0.40-dev1,还要修改utils文件的526行

    yield next(seq)

    to:

    try:
        yield next(seq)
    except StopIteration:
        return

    做这个之前,请先卸载之前的安装pip uninstall web.py

    斑比站在你身...

    修改格式具体是什么? 改了后还是不对

    2019-03-13 11:20:18

    共 2 条回复 >

  • 慕九州008247
    2018-09-30 09:06:23

    To judge from the file paths, it looks like you're running Python 3.7. If so, you're getting caught by new-in-3.7 behavior described here:

    PEP 479 is enabled for all code in Python 3.7, meaning that StopIteration exceptions raised directly or indirectly in coroutines and generators are transformed into RuntimeError exceptions. (Contributed by Yury Selivanov in bpo-32670.)

    Before this change, a StopIteration raised by, or passing through, a generator simply ended the generator's useful life (the exception was silently swallowed). The module you're using will have to be recoded to work as intended with 3.7.

    Chances are they'll need to change:

    yield next(seq)

    to:

    try:
        yield next(seq)
    except StopIteration:
        return


python-web.py开发入门

web.py开发入门入门教程,讲解一个你最快能学会的web开发的框架

58639 学习 · 106 问题

查看课程

相似问题