Skip to main content
 首页 » 编程设计

python之如何将多个参数传递给函数

2025年05月04日23soundcode

<分区>

我正在尝试解析一个 json 文件,假设被调用的函数从一个名为 section1

的变量中获取 json 路径
def traverseJson(arg1): 
    #do stuff 
 
section1 = json["section"]["section"][1] 

要调用我要运行的函数:

traverseJson(section1) 

然后我如何将多个参数传递给函数?例如

section2 = json["section"]["subsection"][0] 
section3 = json["section"]["subsection"][0] 

不预定义参数数量的解决方案将更合适,因为参数数量可以变化。