`return line,`和`return line`之间的区别

cjo*_*sen 2 python matplotlib

在我最近的一个问题中,我引用了Jake Vanderplas的一些代码.可以找到以下代码:

from matplotlib import pyplot as plt
from matplotlib import animation

fig = plt.figure()

ax = plt.axes(xlim=(0, 2), ylim=(0, 100))

line, = plt.plot([], [])

def init():
    line.set_data([], [])
    return line,

def animate(i):
    line.set_data([0, 2], [0,i])
    return line,

anim = animation.FuncAnimation(fig, animate, init_func=init,
                               frames=100, interval=20, blit=True)

plt.show()
Run Code Online (Sandbox Code Playgroud)

initor animate函数中,返回"value"是line,(用逗号).

问题:返回"值"是否会有line(whitout逗号)?

谢谢

unu*_*tbu 6

line,是一个元组,其中包含一个对象. line只是线对象.

In [80]: line = object()

In [81]: line,
Out[81]: (<object at 0x9ee7fa8>,)
Run Code Online (Sandbox Code Playgroud)