Python中的“元组不可调用" [英] 'Tuple is not callable' in Python

查看:46
本文介绍了Python中的“元组不可调用"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试绘制类似这样的内容时,我在 Python 中遇到了错误:

I've got error in Python while trying to plot something like this:

import matplotlib.pyplot as plt

plt.plot(list_x,list_y)

正如我在标题中提到的,此错误是:

As I mentioned in title this error is:

'tuple' object is not callable 

我想知道代码有什么问题,但是后来我意识到即使粘贴正确的代码,该错误也会出现(例如:

I was wondering what's wrong with my code, but then I realized that this error appears even when I'm pasting correct code (for example: http://matplotlib.org/examples/pylab_examples/accented_text.html ).

这很奇怪.感谢您提前提供任何帮助提示.

This is weird. Thanks for advance for any helping tips.

推荐答案

正如评论中提到的,你可能不小心覆盖了 plt.plot 的值

As mentioned in the comments, you may have accidentally overwritten the value of plt.plot

Python 2.7.5+ (default, Feb 27 2014, 19:37:08) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib.pyplot as plt
>>> plt.plot
<function plot at 0x2285488>

如果问题在新的解释器中仍然存在,您应该看到 plt.plot 显示的元组是什么.也许这是出了什么问题的线索.

If the problem persists in a new interpreter, you should see what the tuple is that plt.plot displays. Maybe that is a clue to what has gone wrong.

这篇关于Python中的“元组不可调用"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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