Python 如何成功地将变量更改为>;4.

Python 如何成功地将变量更改为>;4.,python,passwords,Python,Passwords,我对python非常陌生,刚刚开始学习基础知识。我的问题是,为什么我可以将每个密码变量的部件数更改为任何数字4或更少,并且程序运行良好,但当我尝试将4更改为7时,我希望程序不会产生任何结果 # Import dependancies import itertools # Create array with known parts of the password parts = ['foo', 'FOO', 'Foo', 'bar', 'BAR', 'Bar', '1', '2', '3', '

我对python非常陌生,刚刚开始学习基础知识。我的问题是,为什么我可以将每个密码变量的部件数更改为任何数字4或更少,并且程序运行良好,但当我尝试将4更改为7时,我希望程序不会产生任何结果

# Import dependancies
import itertools

# Create array with known parts of the password
parts = ['foo', 'FOO', 'Foo', 'bar', 'BAR', 'Bar', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '!', '@', '#', '$', '%', '^', '&', '*']

# Number of parts per password
number = 4

# Build a list of combinations of knows parts with number of parts
permutations = list(itertools.permutations(parts, number))

# Print list
for (i, permutation) in enumerate(permutations):
  print ''.join(permutation)

排列是否会变成一个空列表?当我使用变量1-4运行程序时,它会生成一个包含所有可能组合的列表。当我尝试任何>4的东西时,什么都不会发生。我运行了程序,没有任何错误消息,只是什么都没有。程序没有正确停止吗?您的
零件列表中有25项。当
number
设置为4时,可能的排列数为300000。当您将其设置为5时,它将变为6e6。7岁时,这是一个无法管理的3e9。您的程序在尝试枚举置换时内存不足。不,程序不会停止。