Skip to main content
 首页 » 编程设计

python之将超过 255 个参数传递给函数

2025年05月04日9rubylouvre

我只是将我的参数从 def 语句传递到 def 语句。我不知道您可以通过的参数数量有限制。我假设参数是变量。我需要能够通过超过 255 个。有人可以用外行的方式帮助我如何解决“超过 255 个参数”。谢谢!

代码:

def a(): 
  "Things happening" 
  variable1 
  b(variable1) 
 
def b(variable1): 
  "Things happening" 
  variable2 
  c(variable1, variable2) 
 
def c(variable1, variable2): 
  "Things happening" 
  variable3 
  d(variable1, variable2, variable3) 
. 
. 
. 
def z5(variable1,...variable256): 
  print result 
 
main() 

请您参考如下方法:

在 python 3.7 中,您现在可以传递超过 255 个参数。

看这里:

https://docs.python.org/3.7/whatsnew/3.7.html

https://bugs.python.org/issue12844

https://bugs.python.org/issue18896