擅长:python、mysql、java
<p>这个检查对于模板来说有点复杂,但是您可以使用<a href="https://docs.python.org/3/library/functions.html#any" rel="nofollow noreferrer">^{<cd1>}</a>函数在Python代码中轻松地实现它。
由于字符串较长,您可以检查操作是否是<code>in</code>字符串:</p>
<pre><code>any(
op.lower() in s.lower()
for op in operations)
</code></pre>
<p>测试代码:</p>
<pre><code>content = ['**Added**:\n', '* something (toto-544)\n', '\n', '**Changed**:\n',]
operations = ['Added', 'Changed', 'Fixed', 'INTERNAL']
for s in content:
print()
print('s:', repr(s))
print('s in operations:', s in operations)
print('custom check: ', any(op.lower() in s.lower() for op in operations))
</code></pre>
<p>结果是:</p>
<pre><code>s: '**Added**:\n'
s in operations: False
custom check: True
s: '* something (toto-544)\n'
s in operations: False
custom check: False
s: '\n'
s in operations: False
custom check: False
s: '**Changed**:\n'
s in operations: False
custom check: True
</code></pre>