2024-04-20 01:12:31 发布
网友
有没有可能像javascript那样在python中解压参数?你知道吗
def foo([ arg ]): pass foo([ 42 ])
参数解包是removed in Python 3,因为它很混乱。在python2中,您可以
def foo(arg, (arg2, arg3)): pass foo( 32, [ 44, 55 ] )
python3中的等效代码是
def foo(arg, arg2, arg3): pass foo( 32, *[ 44, 55 ] )
或者
def foo(arg, args): arg2, arg3 = args foo( 32, [ 44, 55 ] )
参数解包是removed in Python 3,因为它很混乱。在python2中,您可以
python3中的等效代码是
或者
相关问题 更多 >
编程相关推荐