擅长:python、mysql、java
<pre><code>>>> def foo(x, *args):
... print "x:", x
... for arg in args: # iterating! notice args is not proceeded by an asterisk.
... print arg
...
>>> foo(1, 2, 3, 4, 5)
x: 1
2
3
4
5
</code></pre>
<p><strong>编辑:</strong>另请参见<a href="http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/" rel="nofollow">How to use *args and **kwargs in Python</a>(由Jeremy D和subhacom引用)。</p>