# str里有多行文字,每行用逗号隔开了,怎么文字组合?
str = '''
今天,明天,后天
知道,不知道
女孩子,Python
'''
# print 打印
'''
今天 知道 女孩
今天 知道 Python
明天 知道 女孩
明天 知道 Python
....
'''
str = '''
今天,明天,后天
知道,不知道
女孩子,Python
'''
import itertools
p = []
for i in list(filter(None, str.split("\n"))):
p.extend([i.split(",")])
pres = list((itertools.product(*p)))
for j in pres:
print(" ".join(j))
str = '''
今天,明天,后天
知道,不知道
女孩子,Python
'''
rows = [row for row in str.split('\n') if row]
# print(rows)
list1 = []
for row in rows:
list1.append(row.split(','))
# print(list1)
list2 = [(x, y, z) for x in list1[0] for y in list1[1] for z in list1[2]]
# print(list2)
for i in list2:
print(' '.join(i))
"""
今天 知道 女孩子
今天 知道 Python
今天 不知道 女孩子
今天 不知道 Python
明天 知道 女孩子
明天 知道 Python
明天 不知道 女孩子
明天 不知道 Python
后天 知道 女孩子
后天 知道 Python
后天 不知道 女孩子
后天 不知道 Python
"""