如何克服Python中的TypeError

2024-10-01 04:59:52 发布

您现在位置:Python中文网/ 问答频道 /正文

def myplo(data, PL):
    for name in PL:
        plt.plot(Points[0], c = Col[name], ls=":", marker= Shape[name], ms= MS[name], label = Players[0])
    plt.legend(loc='upper left', bbox_to_anchor=(1,1))
    plt.xticks(list(range(0,10)), Seasons, rotation= 'vertical')
    plt.show()

词典和所有其他相关功能都已输入。但当我进去的时候 myplot(点)

出现以下错误

TypeError
Traceback (most recent call last) <ipython-input-215-e2827b75a02e> in <module>()
----> 1 myplo(Points)
TypeError: myplo() missing 1 required positional argument: 'PL'

Tags: nameinfordataplotdefpltcol
1条回答
网友
1楼 · 发布于 2024-10-01 04:59:52

stacktrace显示出哪里出了问题。你知道吗

当像您描述的那样以myplot(Points)的形式调用函数时,您只提供了两个必需参数中的一个。 您的函数被定义为def myplo(data, PL):,因此名为PL的参数没有接收任何数据,它是必需的!你知道吗

相关问题 更多 >