擅长:python、mysql、java
<p>你好像在重新发明轮子。我使用了<a href="https://pypi.python.org/pypi/num2words" rel="nofollow">num2words</a>库,而不是不使用单词。这似乎给了我正确的答案。你知道吗</p>
<pre><code>total = 0
for num in range(1, 1001):
total += len(num2words(num).replace(" ", "").replace("-", ""))
print(total)
21124
</code></pre>