发布于 2015-09-11 16:14:56 | 64 次阅读 | 评论: 0 | 来源: 网络整理

#
# The Python Imaging Library.
# $Id$
#
# sequence support classes
#
# history:
# 1997-02-20 fl     Created
#
# Copyright (c) 1997 by Secret Labs AB.
# Copyright (c) 1997 by Fredrik Lundh.
#
# See the README file for information on usage and redistribution.
#

##

[docs]class Iterator: """ This class implements an iterator object that can be used to loop over an image sequence. You can use the ``[]`` operator to access elements by index. This operator will raise an :py:exc:`IndexError` if you try to access a nonexistent frame. :param im: An image object. """ def __init__(self, im): if not hasattr(im, "seek"): raise AttributeError("im must have seek method") self.im = im def __getitem__(self, ix): try: if ix: self.im.seek(ix) return self.im except EOFError: raise IndexError # end of sequence
最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务