Iterate over *args?

后端 未结 7 1439
借酒劲吻你
借酒劲吻你 2020-12-15 07:52

I have a script I\'m working on where I need to accept multiple arguments and then iterate over them to perform actions. I started down the path of defining a function and u

7条回答
  •  感动是毒
    2020-12-15 08:04

    If you do that :

    def test_with_args(farg, *args):
        print "formal arg:", farg
        for arg in args:
            print "other args:", arg
    

    Other information: http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/

提交回复
热议问题