python SyntaxError:位置参数跟随关键字参数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41504587/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:06:29  来源:igfitidea点击:

python SyntaxError: positional argument follows keyword argument

pythonkeyword-argumentpositional-parameter

提问by Atena

I have a python 3 function which is defined like below:

我有一个 python 3 函数,其定义如下:

def hidden_markov_model(distribution, K=3, N=100, *args):

when i call the function, i get this error:

当我调用该函数时,出现此错误:

Q_hmm = hidden_markov_model(Gaussian, K=K, N=N, 
                            mu, K*[std**(-2)*np.identity(2)],
                            )

SyntaxError: positional argument follows keyword argument

what is wrong?

怎么了?

回答by Atena

Understand. I should call it like this:

理解。我应该这样称呼它:

 Q_hmm = hidden_markov_model(Gaussian, K, N, 
                            mu, K*[std**(-2)*np.identity(2)],
                            )