python - 如何制作大量Z1189不同排列的网站?
问题描述
所以我试图找到一个置换字母的不同网站。这是为了寻宝。例如,我需要创建一个这样的链接: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。会像每一页一样。就像这里一样。当我使用控制台输入“打印排列(数据)”时,它只显示一个长文本。用我刚刚删除的东西。像 [, ] 之类的。谁能帮我?
解决方案
推荐阅读
- apache-kafka - Flink:将 flink-sql-connector-kafka 添加到 fat-jar
- python - 从 conv2d 模型预测图像也必须是 4d
- python - 如何从具有请求和 BeautifulSoup4 的动态内容的网站中提取表格数据?
- authentication - winston-elasticsearch:如何将弹性搜索与凭据连接起来?
- c - 是否可以为联合创建数据类型获取器(用 C 语言)?
- python - sockeye 安装版本 2.2.7
- grid - oracle apex 交互式网格中的验证
- javascript - 如何解决:TypeError: __init__() got an unexpected keyword argument 'max_Length' 我什么都试过了
- r - 如何在 R Shiny 中使用变量名访问辅助输入?
- python - 使用 pandas 框架计算空值的数量