视频版教程 Python3零基础7天入门实战视频教程
我们通过元组tuple类型的 *args 来实现,具体看下实例:
def test(*args):
print(args, type(args))
test(1, "2")
test(True, 1, "2", 3.14)
test()
运行输出:
(1, '2') <class 'tuple'>
(True, 1, '2', 3.14) <class 'tuple'>
() <class 'tuple'>
视频版教程 Python3零基础7天入门实战视频教程
我们通过元组tuple类型的 *args 来实现,具体看下实例:
def test(*args):
print(args, type(args))
test(1, "2")
test(True, 1, "2", 3.14)
test()
运行输出:
(1, '2') <class 'tuple'>
(True, 1, '2', 3.14) <class 'tuple'>
() <class 'tuple'>