我想基于类似于下面的逻辑将某些标志传递给re.compile函数.我想知道是否可以这样做.
flags = ""
if multiline:
flags = 're.M'
if dotall:
flags = flags + '|re.S'
if verbose:
flags = flags + '|re.X'
if ignorecase:
flags = flags + '|re.I'
if uni_code:
flags = flags + '|re.U'
regex = re.compile(r'Test Pattern', flags)
Run Code Online (Sandbox Code Playgroud) 我有三个Numpy矩阵
a = np.matrix('1 2; 3 4')
b = np.matrix('5 6 7; 8 9 10')
c = np.matrix('1 2 3; 4 5 6; 7 8 9')
我想制作以下块矩阵:
M = [a b ; 0 c]
,
其中0
代表具有相关尺寸的零矩阵.