擅长:python、mysql、java
<p>您可以尝试使用装饰器:</p>
<pre><code>def capture(func):
capture.kwds = None
def wrap(*args, **kwargs):
capture.kwds = kwargs
return func(*args, **kwargs)
return wrap
@capture
def foo(limit=None, offset=None, lower_bound=None, upper_bound=None):
return None
</code></pre>
<p>现在您可以拨打:</p>
<pre><code>>>> foo(limit=1, offset=2, lower_bound=3, upper_bound=4)
None
>>> capture.kwds
{'limit': 1, 'offset': 2, 'lower_bound': 3, 'upper_bound': 4}
</code></pre>