import itertools lst = [112, 123, 98, 132, 120] list(itertools.permutations(lst,2)) # 输出: # [(112, 123), # (112, 98), # (112, 132), # (112, 120), # (123, 112), # (123, 98), # (123, 132), # (123, 120), # (98, 112), # (98, 123), # (98, 132), # (98, 120), # (132, 112), # (132, 123), # (132, 98), # (132, 120), # (120, 112), # (120, 123), # (120, 98), # (120, 132)] list(itertools.combinations(lst, 2)) # 输出: # [(112, 123), # (112, 98), # (112, 132), # (112, 120), # (123, 98), # (123, 132), # (123, 120), # (98, 132), # (98, 120), # (132, 120)]
users = ['user1', 'user2', 'user3', 'user4'] passwords = ['pass1', 'pass2', 'pass3', 'pass4'] list(itertools.product(users, passwords)) # 输出: # [('user1', 'pass1'), # ('user1', 'pass2'), # ('user1', 'pass3'), # ('user1', 'pass4'), # ('user2', 'pass1'), # ('user2', 'pass2'), # ('user2', 'pass3'), # ('user2', 'pass4'), # ('user3', 'pass1'), # ('user3', 'pass2'), # ('user3', 'pass3'), # ('user3', 'pass4'), # ('user4', 'pass1'), # ('user4', 'pass2'), # ('user4', 'pass3'), # ('user4', 'pass4')]
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/119504.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...