Function python函数参数:在同一参数中使用任一选项(';*';和';=';)

Function python函数参数:在同一参数中使用任一选项(';*';和';=';),function,parameters,python-3.5,Function,Parameters,Python 3.5,我一直在写代码,但函数参数有问题。职能: def seven_zip_file_extract(self,filename,*file ="" ): command = "7za e {}.7z" if *file=="": os.system(command) else: command = self.expand(command,*file) os.system(command) *file=”“的语法无效。我怎样才能

我一直在写代码,但函数参数有问题。职能:

def seven_zip_file_extract(self,filename,*file ="" ):
    command = "7za e {}.7z"
    if *file=="":
        os.system(command)
    else:
        command = self.expand(command,*file)
        os.system(command)
*file=”“
的语法无效。我怎样才能修好它

我需要“*file”参数,因为用户可以输入一个输入,并且该输入可以包含多个参数,但我需要为用户定义一些东西,而不是输入情况。用于更好解释的代码:

def define_func(parameter1,parameter2="std_define"):
    pass
当我调用该函数时,我需要输入参数1才能工作,但参数2不是必需的。该函数将在任何情况下工作

define_func(val1)#Situation1


define_func(val1,val2)#Situation2
对于表示一个或多个值代码的参数,“*”:

def multi(parameter1,*parameters):
    pass
比如打电话

multi(val1,vala1,vala2,vala3,vala4)
valax输入将存储在
参数
值中。我想将其与选项组合


还有一个问题。
if*file==”
的语法正确吗?

我一直在解决它。
*参数
已经完成了定义人员的工作。这是固定代码:

    def seven_zip_file_extract(self,filename,*file):
        command = "7za e {}.7z".format(filename)
        if file==None:
            os.system(command)
        else:
            command = self.expand(command,*file)
            os.system(command)