0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

itertoolsを用いた要素の組み合わせの取得

Posted at

複数のリストの内容の組み合わせ一覧を取得するために、itertools.productというメソッドを使用すると非常に便利

Input = ["Docment","StyleSheet","Value"]
Output = ["XML","Shema","DTD"]
Action = ["Read","Write","GetRoot","EditSubELM","EditDescELM","Append","Insert","Iterate","Find","Format"]

writeObj = list(itertools.product(Input,Output,Action))

with open("write.txt","w") as writer:
    writer.write(str(writeObj))
    writer.close()

出力結果は次の通り。

('Docment', 'XML', 'Read')
('Docment', 'XML', 'Write')
('Docment', 'XML', 'GetRoot')
('Docment', 'XML', 'EditSubELM')
('Docment', 'XML', 'EditDescELM')
('Docment', 'XML', 'Append')
('Docment', 'XML', 'Insert')
('Docment', 'XML', 'Iterate')
('Docment', 'XML', 'Find')
('Docment', 'XML', 'Format')
('Docment', 'Shema', 'Read')
('Docment', 'Shema', 'Write')
('Docment', 'Shema', 'GetRoot')
('Docment', 'Shema', 'EditSubELM')
('Docment', 'Shema', 'EditDescELM')
('Docment', 'Shema', 'Append')
('Docment', 'Shema', 'Insert')
('Docment', 'Shema', 'Iterate')
('Docment', 'Shema', 'Find')
('Docment', 'Shema', 'Format')
('Docment', 'DTD', 'Read')
('Docment', 'DTD', 'Write')
('Docment', 'DTD', 'GetRoot')
('Docment', 'DTD', 'EditSubELM')
('Docment', 'DTD', 'EditDescELM')
('Docment', 'DTD', 'Append')
('Docment', 'DTD', 'Insert')
('Docment', 'DTD', 'Iterate')
('Docment', 'DTD', 'Find')
('Docment', 'DTD', 'Format')
('StyleSheet', 'XML', 'Read')
('StyleSheet', 'XML', 'Write')
('StyleSheet', 'XML', 'GetRoot')
('StyleSheet', 'XML', 'EditSubELM')
('StyleSheet', 'XML', 'EditDescELM')
('StyleSheet', 'XML', 'Append')
('StyleSheet', 'XML', 'Insert')
('StyleSheet', 'XML', 'Iterate')
('StyleSheet', 'XML', 'Find')
('StyleSheet', 'XML', 'Format')
('StyleSheet', 'Shema', 'Read')
('StyleSheet', 'Shema', 'Write')
('StyleSheet', 'Shema', 'GetRoot')
('StyleSheet', 'Shema', 'EditSubELM')
('StyleSheet', 'Shema', 'EditDescELM')
('StyleSheet', 'Shema', 'Append')
('StyleSheet', 'Shema', 'Insert')
('StyleSheet', 'Shema', 'Iterate')
('StyleSheet', 'Shema', 'Find')
('StyleSheet', 'Shema', 'Format')
('StyleSheet', 'DTD', 'Read')
('StyleSheet', 'DTD', 'Write')
('StyleSheet', 'DTD', 'GetRoot')
('StyleSheet', 'DTD', 'EditSubELM')
('StyleSheet', 'DTD', 'EditDescELM')
('StyleSheet', 'DTD', 'Append')
('StyleSheet', 'DTD', 'Insert')
('StyleSheet', 'DTD', 'Iterate')
('StyleSheet', 'DTD', 'Find')
('StyleSheet', 'DTD', 'Format')
('Value', 'XML', 'Read')
('Value', 'XML', 'Write')
('Value', 'XML', 'GetRoot')
('Value', 'XML', 'EditSubELM')
('Value', 'XML', 'EditDescELM')
('Value', 'XML', 'Append')
('Value', 'XML', 'Insert')
('Value', 'XML', 'Iterate')
('Value', 'XML', 'Find')
('Value', 'XML', 'Format')
('Value', 'Shema', 'Read')
('Value', 'Shema', 'Write')
('Value', 'Shema', 'GetRoot')
('Value', 'Shema', 'EditSubELM')
('Value', 'Shema', 'EditDescELM')
('Value', 'Shema', 'Append')
('Value', 'Shema', 'Insert')
('Value', 'Shema', 'Iterate')
('Value', 'Shema', 'Find')
('Value', 'Shema', 'Format')
('Value', 'DTD', 'Read')
('Value', 'DTD', 'Write')
('Value', 'DTD', 'GetRoot')
('Value', 'DTD', 'EditSubELM')
('Value', 'DTD', 'EditDescELM')
('Value', 'DTD', 'Append')
('Value', 'DTD', 'Insert')
('Value', 'DTD', 'Iterate')
('Value', 'DTD', 'Find')
('Value', 'DTD', 'Format')
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?