TypeError: 'range' object is not callable

    xiaoxiao2022-07-02  133

    TypeError: 'range' object is not callable

    In python 3, range returns an iterator, not a list itself. The following does hence not work with python 3. It does however, with python 2.

    import seaborn as sns import matplotlib.pyplot as plt x = range(9) y = [1,2,3]*3 sns.pointplot(x=x, y=y, markers = '.') plt.show()

    However, you may convert any range to a list via list(range(...)). Hence the following works fine.

    import seaborn as sns import matplotlib.pyplot as plt x = list(range(9)) y = [1,2,3]*3 sns.pointplot(x=x, y=y, markers = '.') plt.show()

     

    一句话解决:

    在你自己的代码上

    range()前面有list就去掉。没有就加上

    问题解决

     

     

     

    最新回复(0)