如何编辑排列
每个数字都是端口。 排列为我提供了所有可能的路线,但是我的起始端口始终是1号,所以在所有组合中,我想要以1开始的组合。
就是我到目前为止的全部
from itertools import permutations
routes = permutations([1 , 2, 3 ,4 , 5])
for i in list(routes):
print(i)
这 ?
every number is a port.
and the permutation gives me all possible routes but my starting port is always number 1,so out of all combinations i want the ones that start with 1.
this is all i got so far
from itertools import permutations
routes = permutations([1 , 2, 3 ,4 , 5])
for i in list(routes):
print(i)
is there a way to enable me to pick those specific combinations?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以简单地将1添加到2,3,4,5的排列开始。例如,
如果您真的想生成所有置换量并将其滤除到以1开始的置换,则可以执行以下操作。
You could simply add a 1 to the beginning of the permutations of 2,3,4,5. For example,
If you really want to generate every permutation and filter down to those starting with 1, you could do the following.