Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python循环-AttributeError:';非类型';对象没有属性';执行';_Python - Fatal编程技术网

Python循环-AttributeError:';非类型';对象没有属性';执行';

Python循环-AttributeError:';非类型';对象没有属性';执行';,python,Python,我正在使用while循环执行一些代码: while (totalIter > 0): totalIter = totalIter - 1 route_data = yield Runner.execute(endpoint, endpoint.config, command, send_data) 其中,Runner作为从prov.runners.base导入Runner yield语句第一次运行良好,但在第二次执行循环时,它抛出以下错误 AttributeError:“

我正在使用
while
循环执行一些代码:

while (totalIter > 0):
    totalIter = totalIter - 1
    route_data = yield Runner.execute(endpoint, endpoint.config, command, send_data)
其中,
Runner
作为
从prov.runners.base导入Runner

yield
语句第一次运行良好,但在第二次执行循环时,它抛出以下错误

AttributeError:“非类型”对象没有属性“执行”

表示
Runner
已变为
None

我试过做一些事情,但没有用

import prov.runners.base     
while (totalIter > 0):
        totalIter = totalIter - 1
        reload(prov.runners.base.Runner)
        route_data = yield prov.runners.base.Runner.execute(endpoint, endpoint.config, command, send_data)
这会产生错误:

AttributeError:“非类型”对象没有属性“runners”

第二次执行时,指示
prov
None

仅尝试重新加载
Runner
,但python给出了错误,即
reload需要将模块作为参数。


这个问题是否与模块加载或其他问题有关?

与您的问题无关,但是否有任何特殊原因导致您使用while循环进行迭代,并手动递减,而不是对范围内的(totalIter)执行
?如果将
route\u data=yield…
替换为
print(Runner)
?python新手,如果改为for循环,效果会更好:)@Jean Françoisfare工作良好,打印
的次数与循环执行次数相同。似乎是
yield
导致了问题。好的,然后尝试生成一些无关的内容。