from itertools import productL1 = 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 = 1for i in l: if n%4 == 0: print(i) else: print(i, end ='') n = n + 1
中間接不上,怎麼等於n循環笛卡爾積的結果?
f=lprint(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)