2015-11-04 83 views
0

我是新來的Python和編碼(昨晚)。我需要爲輸出生成具有特定格式的大量itertools產品。我可以用產生的組合,格式輸出Itertools.Products

import itertools 
s=[ ['CPT1','OTHERCPT1','OTHERCPT2','OTHERCPT3','OTHERCPT4','OTHERCPT5','OTHERCPT6','OTHERCPT7','OTHERCPT8','OTHERCPT9','OTHERCPT10','CONCURR1','CONCURR2','CONCURR3','CONCURR4','CONCURR5','CONCURR6','CONCURR7','CONCURR8','CONCURR9','CONCURR10'], ['15756','15757','15758','43496','49006','20969','20955','20956','20957','20962','20970','20972','20973'],['CPT1','OTHERCPT1','OTHERCPT2','OTHERCPT3','OTHERCPT4','OTHERCPT5','OTHERCPT6','OTHERCPT7','OTHERCPT8','OTHERCPT9','OTHERCPT10','CONCURR1','CONCURR2','CONCURR3','CONCURR4','CONCURR5','CONCURR6','CONCURR7','CONCURR8','CONCURR9','CONCURR10'], ['15756','15757','15758','43496','49006','20969','20955','20956','20957','20962','20970','20972','20973']] 
x=list(itertools.product(*s)) 
print x 

但是輸出顯示爲這樣:

('CPT1', '15756', 'CPT1', '15756'), ... etc. 

我想它顯示:

SELECT IF(CPT1='15756' AND CPT1='15756'). 
SELECT IF(...). 
etc. 

感謝您的幫助!

+0

所以寫代碼來構建一些字符串與'被格式化你所希望的方式.format' ...所以不是一個代碼編寫的服務。 –

+0

我會盡力與此合作。不要試圖讓任何人爲我做我的工作,但沒有任何知識基礎。抱歉。 – commodoreMD

+0

有很多偉大的在線學習python資源。跳入並教育你自己:) –

回答