擅长:python、mysql、java
<p>我想这就是你要找的</p>
<pre><code>set_a = [ 'foo/BAR', 'foo/XYZ', 'foo/ABC', 'foo/123' ]
set_b = [ 'ABC', 'ZYX', '123', 'BAR' ]
def parse_from_a(x):
if '/' in x:
return x.split('/')[1]
# add more parsing logic here
return x
fixed_set_a = {parse_from_a(x) for x in set_a}
fixed_set_b = set(set_b)
print(fixed_set_a - fixed_set_b)
</code></pre>
<p>它打印单个项目集:</p>
<blockquote>
<p>{'XYZ'}</p>
</blockquote>