[英]type error: 'module' object is not callable
I just started using python and I get an error when I try to copy an object:我刚开始使用 python,当我尝试复制对象时出现错误:
import numpy
import copy
c = numpy.zeros(10)
t = copy(c)
Running the code I encountered this error that I can not solve, could you help me?运行代码我遇到了这个我无法解决的错误,你能帮我吗? Thank you all谢谢你们
Traceback (most recent call last):
File "sage_server.py", line 5, in <module>
t = copy(c)
TypeError: 'module' object is not callable
You might be invoking a module as a function (as suggested by the error message).您可能将模块作为函数调用(如错误消息所建议的那样)。
>>> import copy
>>> type(copy)
<type 'module'>
Instead, what you seem to need is the copy() function, that is included in that module.相反,您似乎需要的是包含在该模块中的copy()函数。
>>> type(copy.copy)
<type 'function'>
For that, you would need to do something like:为此,您需要执行以下操作:
>>> copy.copy(c)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.