遇到報錯AttributeError: 'itertools.cycle' object has no attribute 'next'
阿新 • • 發佈:2018-11-30
問題
我在寫下面的程式時,遇到報錯提示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), )) )