0
나는 python 2.7 iter.product를 사용하여 3 개의 데이터 세트의 데카르트 곱을 생성합니다.itertools.product에 의해 생성 된 데이터 세트에 레이블 추가하기
이것은 세 개의 중첩 루프와 같습니다. 그러나 루프를 입력하기 전에 레이블 "과일 유형 :"및 "트리 유형 :"을 인쇄하고 싶습니다. 명확하지 않으면 Ive는 내가 원하는 출력의 예를 넣습니다.
무엇을 할 파이썬 방법은 데카르트를 생성 할 수 있습니다. 제품을 사후 처리에서 레이블을 추가하지만 메모리 풋 프린트를 줄이기 위해 itertools를 사용하는 목적을 무효화하지는 않습니까?
출력이는 방법입니다
*************************************** Fruit Type: apple *************************************** --------------------------------------- Tree Type: ash --------------------------------------- fruit is apple, tree is ash, animal is dog fruit is apple, tree is ash, animal is cat fruit is apple, tree is ash, animal is horse --------------------------------------- Tree Type: oak --------------------------------------- fruit is apple, tree is oak, animal is dog fruit is apple, tree is oak, animal is cat fruit is apple, tree is oak, animal is horse --------------------------------------- Tree Type: beech --------------------------------------- fruit is apple, tree is beech, animal is dog fruit is apple, tree is beech, animal is cat fruit is apple, tree is beech, animal is horse --------------------------------------- Tree Type: ash --------------------------------------- *************************************** Fruit Type: orange *************************************** --------------------------------------- Tree Type: ash --------------------------------------- fruit is orange, tree is ash, animal is dog fruit is orange, tree is ash, animal is cat fruit is orange, tree is ash, animal is horse --------------------------------------- Tree Type: oak --------------------------------------- fruit is orange, tree is oak, animal is dog fruit is orange, tree is oak, animal is cat fruit is orange, tree is oak, animal is horse --------------------------------------- Tree Type: beech --------------------------------------- fruit is orange, tree is beech, animal is dog fruit is orange, tree is beech, animal is cat fruit is orange, tree is beech, animal is horse *************************************** Fruit Type: pear *************************************** --------------------------------------- Tree Type: ash --------------------------------------- fruit is pear, tree is ash, animal is dog fruit is pear, tree is ash, animal is cat fruit is pear, tree is ash, animal is horse --------------------------------------- Tree Type: oak --------------------------------------- fruit is pear, tree is oak, animal is dog fruit is pear, tree is oak, animal is cat fruit is pear, tree is oak, animal is horse --------------------------------------- Tree Type: beech --------------------------------------- fruit is pear, tree is beech, animal is dog fruit is pear, tree is beech, animal is cat fruit is pear, tree is beech, animal is horse