在源代码中需要什么样的变化?python3类型错误:“功能”对象不是可迭代
def Update(): print('\n') print("Update") cmd = os.system('xterm -e apt-get update') print("Finish update") def AptUpdate(): print('\n') print("Update system? {Y/N}") print("Y or y") print("N or n") code = input("Command > ") if code == 'y' or code == 'Y': for i in Update(): return Update elif code == 'n' or code == 'N': return else: print("Warning!") AptUpdate() exception: Traceback (most recent call last): File "pybash.py", line 110, in AptUpdate() File "pybash.py", line 102, in AptUpdate for i in Update: TypeError: 'function' object is not iterable
你的回溯和实际的代码不匹配。问题就出在这两个。 –
之间准确的区别你的下一个错误将是''NoneType '对象不可迭代',因为'Updt'实际上不会返回任何东西有用的东西。 –
你应该读作[Python中的回报与印刷之间的区别是什么?(http://stackoverflow.com/q/3881434/4279)和[Python的:什么是打印和收益之间的形式上的差别(HTTP:// stackoverflow.com/q/7664779/4279) – jfs