Python 忽略循环中的某些元组

Python 忽略循环中的某些元组,python,Python,我正在生成一些元组中的动画帧,其中可能包含0,0值,我希望在使用moviepy生成帧时忽略这些值。xy在循环中包含以下内容。第一次和第二次迭代包含0,0,其余包含浮点。我想忽略那些拥有0,0的迭代。可以用moviepy的make_framet def完成吗?我需要一些建议 (0, 0) (0, 0) (82.5, 82.5) (82.5, 82.5) (108.28125, 108.28125) (108.28125, 108.28125) 我收到以下错误: Traceback (most r

我正在生成一些元组中的动画帧,其中可能包含0,0值,我希望在使用moviepy生成帧时忽略这些值。xy在循环中包含以下内容。第一次和第二次迭代包含0,0,其余包含浮点。我想忽略那些拥有0,0的迭代。可以用moviepy的make_framet def完成吗?我需要一些建议

(0, 0)
(0, 0)
(82.5, 82.5)
(82.5, 82.5)
(108.28125, 108.28125)
(108.28125, 108.28125)
我收到以下错误:

Traceback (most recent call last):
  File "C:\vhosts\VIDEO_TWO_CLONE\vapory-examples-master\scene9.py", line 151, in <module>
    clip = VideoClip(make_frame, duration=5)
  File "C:\Anaconda64\lib\site-packages\moviepy\video\VideoClip.py", line 103, in __init__
    self.size = self.get_frame(0).shape[:2][::-1]
AttributeError: 'NoneType' object has no attribute 'shape'
Process terminated with an exit code of 1
在代码中,您有if strxy=='0,0',而实际上这应该是if strxy=='0,0',注意元组中的空格;这就是元组在Python中转换为字符串的方式。但是,更好的方法是,如果xy==0,0,则此处的空格不重要,因为没有转换为字符串。

您错过了if strxy==0,0中的引号
def make_frame(t):

    # PREPARE A DRAWING SURFACE
    surface = gizeh.Surface(width=W, height=H, bg_color=(0,0,0)) # in pixels

    p = PointAnimation((0,0), (110,110), tween=['easeOutElastic', 1, 0.2])

    xy = p.make_frame(t, 0.2, 1, 4, 5)

    if str(xy) == '(0,0)':
        circle = gizeh.circle(r=30, xy=xy, fill=(1,1,0))
        circle.draw(surface) # draw the circle on the surface
        return surface.get_npimage()


clip = VideoClip(make_frame, duration=5)
clip.write_gif("circle.gif", fps=25, fuzz=10)