擅长:python、mysql、java
<p>请检查这个问题(对我有效):
<a href="https://stackoverflow.com/questions/34115298/how-do-i-get-the-current-depth-of-the-python-interpreter-stack">How do I get the current depth of the Python interpreter stack?</a></p>
<p>基于这个答案的代码:</p>
<pre><code>import sys
import inspect
print(sys.getrecursionlimit())
def test_(x,t):
print len(inspect.stack())
x = x+1
if x<t:
test_(x=x,t=t)
print(test_(0,7))
</code></pre>
<p>输出:</p>
<pre><code>22
23
24
25
26
27
28
None
</code></pre>