遇到报错AttributeError: 'itertools.cycle' object has no attribute 'next'

问题

我在写下面的程序时,遇到报错提示AttributeError: 'itertools.cycle' object has no attribute 'next'

menu_options = (('Say Hello', icons.next(), hello),
                    ('Switch Icon', None, switch_icon),
                    ('A sub-menu', icons.next(), (('Say Hello to Simon', icons.next(), simon),
                                                  ('Switch Icon', icons.next(), switch_icon),
                                                 ))
                   )

解决方法

这是因为版本问题,只要将程序icon.next()改成next(icon)就好了。

    menu_options = (('Say Hello', next(icons), hello),
                    ('Switch Icon', None, switch_icon),
                    ('A sub-menu', next(icons), (('Say Hello to Simon', next(icons), simon),
                                                  ('Switch Icon', next(icons), switch_icon),
                                                 ))
                   )

猜你喜欢

转载自blog.csdn.net/maqunfi/article/details/82940984
今日推荐