擅长:python、mysql、java
<p>你可以把你的句子分成单词,然后试着把这个单词转换成整数。如果演员失败了,那就用康卡</p>
<pre><code>a = "Hans went to house number 10 92384 29349"
res = ""
for word in a.split():
try:
number = int(word)
res += " | %d" % number
except ValueError:
res += " %s" % word
</code></pre>
<hr/>
<p><strong>编辑:</strong>我试图给出“最简单”的解决方案。我是说,它比较长,但我想更容易理解。不过,如果你了解其他解决方案(1行),那就去做吧。在</p>