NameError:未定义名称“重新加载" [英] NameError: name 'reload' is not defined

查看:63
本文介绍了NameError:未定义名称“重新加载"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 python 3.2.2.当我写一个简单的程序时,我遇到了问题.

<预><代码>>>>重新加载(推荐)回溯(最近一次调用最后一次):文件<pyshell#6>",第 1 行,在 <module> 中重新加载(推荐)NameError:未定义名称重新加载"

我该怎么做?

解决方案

您可能想要 importlib.reload().

from importlib import reload

在 Python 2.x 中,这是一个 内置,但是在 3.x 中,它位于 importlib 模块中.

请注意,在解释器之外使用 reload() 通常是不必要的,您在这里尝试做什么?

I'm using python 3.2.2. When I write a simple program, I meet the problem.

>>> reload(recommendations)
Traceback (most recent call last):
  File "<pyshell#6>", line 1, in <module>
    reload(recommendations)
NameError: name 'reload' is not defined

How should I do it?

解决方案

You probably wanted importlib.reload().

from importlib import reload

In Python 2.x, this was a builtin, but in 3.x, it's in the importlib module.

Note that using reload() outside of the interpreter is generally unnecessary, what were you trying to do here?

这篇关于NameError:未定义名称“重新加载"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆