python中的print(*args)和print(args)有什么区别

2024-04-25 01:34:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我想了解print(*args)print(args)之间的区别

我有两个非常简单的函数:

def print_args(*args):
    print(args)

def print_xargs(*args):
    print(*args)


print_args(1, 2, 3)
print_xargs(1, 2, 3)

输出:

1, 2, 3 (looks like an exact dublicate of the function input)
(1, 2, 3)

args(without asterisk) in function is just a tuple, but what is *args, does it have any type?


Tags: ofthe函数anisdefargsfunction