Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/google-maps/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Itertools和自定义列表_Python_Itertools - Fatal编程技术网

Python Itertools和自定义列表

Python Itertools和自定义列表,python,itertools,Python,Itertools,因此,我有一个团队列表: teams = ["Team A", "Team B", "Team C", "Team D",] # ... etc. 我想做的是找到这些球队之间存在的所有可能的比赛。我想我可以做到这一点: for x in itertools.product(teams,teams): teams_list.append([x[0],x[1]]) 最后,我要做的是运行一个检查,以确保每个匹配都在其中一次,以及获取每个匹配并从这两个名称创建一个唯一的url字符串。这是正确的

因此,我有一个团队列表:

teams = ["Team A", "Team B", "Team C", "Team D",] # ... etc.
我想做的是找到这些球队之间存在的所有可能的比赛。我想我可以做到这一点:

for x in itertools.product(teams,teams):
   teams_list.append([x[0],x[1]])
最后,我要做的是运行一个检查,以确保每个匹配都在其中一次,以及获取每个匹配并从这两个名称创建一个唯一的url字符串。这是正确的方法吗?因为当我尝试处理团队列表时,我遇到了元组问题。

你想要的,而不是
产品

teams_list = list(itertools.combinations(teams, 2))