因此,我试图找到不同的网站,一个排列的信件。这是用于地理缓存的。例如,我需要做一个这样的链接:http://geocaching.com/geocache/GCZ1189 所以我想在我的浏览器中打开120种不同的排列。唯一的区别是“Z1189”,链接的其余部分将保持不变:)
所以我在网上找到了这个代码。并尝试最后一部分作为测试。但是没有成功
# Python function to print permutations of a given list
def permutation(lst):
# If lst is empty then there are no permutations
if len(lst) == 0:
return []
# If there is only one element in lst then, only
# one permuatation is possible
if len(lst) == 1:
return [lst]
# Find the permutations for lst if there are
# more than 1 characters
l = [] # empty list that will store current permutation
# Iterate the input(lst) and calculate the permutation
for i in range(len(lst)):
m = lst[i]
# Extract lst[i] or m from the list. remLst is
# remaining list
remLst = lst[:i] + lst[i+1:]
# Generating all permutations where m is first
# element
for p in permutation(remLst):
l.append([m] + p)
return l
data = list('Z1189')
for p in permutation(data):
print (p)
#I've made this below. Not working as I wanting it to though
for p in permutation(data):
o = list(p)
o = ''.join(o)
permutation(data).append(o)
print(o)
所以我想让它打开所有不同的网页,可以用这个排列。与Z1189的链接。但是http://geocaching.com/geocache/GC。每一页都会是这样。就像这里一样。当我使用控制台键入“打印排列(数据)”时,它只显示一个长文本。用我刚刚删除的东西。像[,]之类的。有人能帮我吗
目前没有回答
相关问题 更多 >
编程相关推荐