擅长:python、mysql、java
<p>您可以使用我的答案<a href="https://stackoverflow.com/a/59985910/12366110">here</a>的改编:</p>
<p><strong>代码:</strong></p>
<pre><code>def splitter(n):
s = str(n)
for i in range(1, len(s)):
start = s[0:i]
end = s[i:]
yield [int(start), int(end)]
for split in splitter(end):
result = [start]
result.extend(split)
yield list(int(x) for x in result)
</code></pre>
<p><strong>用法:</strong></p>
<pre><code>for x in splitter(3147):
print(x)
</code></pre>
<p><strong>输出:</strong></p>
<pre><code>[3, 147]
[3, 1, 47]
[3, 1, 4, 7]
[3, 14, 7]
[31, 47]
[31, 4, 7]
[314, 7]
</code></pre>