from itertools import product
L1 = list("abcd")
L2 = list("+-*/")
L3 = list("x")
L4 = list("=><≈")
L5 = list("1")
l = []
for X2,X3,X4,X5,X1 in product(L2,L3,L4,L5,L1):
s = X1+X2+X3+X4+X5
l.append(s.replace(" ", ""))
n = 1
for i in l:
if n%4 == 0:
print(i)
else:
print(i, end ='')
n = n + 1
中间接不上,怎么等于n循环笛卡尔积的结果?
f=l
print(f,end = "\t")
a = ["a", "b"] # 准备查找替换的词
b = ["一", "我"] #替换者
import re # 导入库
dic = dict(zip(a,b)) #替换字典
pattern = re.compile('(' + '|'.join(a) + ')')
s = pattern.sub(lambda g:dic[g.group()],k)
print(s)