简体   繁体   English

语法错误:无法分配给函数调用

[英]Syntax Error :can't assign to function call

This is my code below 这是我的下面的代码

plt.figure(1), plt.subplot(121), df=train.dropna(),
sns.distplot(df['LoanAmount'])

I am getting an error like this 我收到这样的错误

> SyntaxError: can't assign to function call

There are a few things wrong with the code, but I will point out the major points: 该代码有一些错误,但是我要指出要点:

plt.figure(1), plt.subplot(121), df=train.dropna(), sns.distplot(df['LoanAmount'])

The commas are interpreted as the line being a tuple, with the equals indicating left and right hand sides, in the same way that 逗号被解释为该行是一个元组,等号表示左侧和右侧,方式与

x, y, z = 1, 2, 3

Would be, ie: 将是,即:

plt.figure(1), plt.subplot(121), df =
    train.dropna(), sns.distplot(df['LoanAmount'])

. What you probably meant was 你可能的意思是

plt.figure(1)
plt.subplot(121)
df = train.dropna()
sns.distplot(df['LoanAmount'])

which you could write (not advisable) as 你可以写(不建议)为

plt.figure(1); plt.subplot(121); df=train.dropna(); sns.distplot(df['LoanAmount'])

The main error you see is correct, you can't have a line like 您看到的主要错误是正确的,您不能有这样的行

a() = b

That assigns to a function call (it would have no meaning), which you do in the original interpretation. 这将分配给您在原始解释中所做的功能调用(没有任何意义)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM