擅长:python、mysql、java
<p>我认为发电机的效率相当高。我想要这样的东西:</p>
<pre><code>from itertools import count, izip
def genThueMorse():
tms = [0]
invert = [1, 0]
for tm, curr in izip(tms, count()):
yield str(tm)
if curr == len(tms) - 1:
tms += [invert[c] for c in tms]
</code></pre>