gpt4 book ai didi

python - 艰难地学习 Python 练习 18 帮助

转载 作者:太空狗 更新时间:2023-10-30 02:50:02 26 4
gpt4 key购买 nike

我了解除第一个以外的所有功能。 (*args) 是什么意思?

谢谢

def print_twice(*args):
arg1, arg2 = args
print 'arg1: %r arg2: %r' % (arg1, arg2)

def print_twice_again(arg1, arg2):
print 'arg1: %r arg2: %r' % (arg1, arg2)

def print_once(arg1):
print 'arg1: %r' % arg1

def print_none():
print 'i got nothin...'

print_twice("neil", "harper")
print_twice_again("neil", "harper")
print_once("first!")
print_none()

最佳答案

一个星号指定一个列表,两个星号指定一个字典。

关于python - 艰难地学习 Python 练习 18 帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5218993/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com