擅长:python、mysql、java
<p>我想我的答案是基于一个<code>collections.Counter()</code>的。它将为你做一些工作</p>
<pre><code>import collections
addresses = ['example@company.com', 'example@company.com', 'none@comapny.com', 'example@company.com']
results = []
for address, count in collections.Counter(addresses).items():
# add a "first" address as is
results.append(address)
# If there were other occurrences add them
for i in range(1, count):
results.append(f"{i+1}@".join(address.split("@")))
print(results)
</code></pre>
<p>这应该给你:</p>
<pre><code>['example@company.com', 'example2@company.com', 'example3@company.com', 'none@comapny.com']
</code></pre>