以元组形式传递多个参数

这个问题在这里已经有了答案:

  • **(双星/星号)和*(星号/星号)对参数做什么? 15个答案

  • 您可以使用*运算符来解压参数列表:

    input_tuple = (1,2,3)
    instance_1 = InputStuff(*input_tuple)
    

    您正在寻找: Unpacking Argument Lists

    >>> range(3, 6)             # normal call with separate arguments
    [3, 4, 5]
    >>> args = [3, 6]
    >>> range(*args)            # call with arguments unpacked from a list
    [3, 4, 5]
    
    链接地址: http://www.djcxy.com/p/9067.html

    上一篇: Pass multiple arguments in form of tuple

    下一篇: What does python zip(*X) do with "*"(asterisk)?