我第一次从笔记本上运行这段代码时,它运行得很好:
#Which letters and how many
letters = ["a","b","c"]
noOfLetters = len(letters)
#Looking for all permutations
resultA = []
from itertools import permutations
for i in range(noOfLetters):
resultA.append(list(permutations(letters,i+1)))
如果我再次运行它(而不重新启动内核),则会出现以下错误:
^{pr2}$
假设“notebook”是Jupyter(以前是ipython notebooks),那么必须注意Jupyter保持所有变量的状态。在
>;这意味着第二次运行开始时,变量已初始化为第一次运行结束时的值。在
避免这种情况的一种方法是重新启动内核;另一种方法是删除所有变量;还有一种方法是每次运行时初始化所有变量。在
从docs:
相关问题 更多 >
编程相关推荐