How can I deal with IndentationError: unexpected indent that is not caused by white space?
How can I deal with IndentationError: unexpected indent that is not caused by white space?
我正在尝试将 MSE 函数从 Matlab 转换为 Python,但出现此错误:
for i in range(len(RuleBase)):
^
IndentationError: unexpected indent
我已经试过 space,除了白色 space 还有什么问题?
这是我在 matlab 中的函数:
function err=Mse(RuleBase,x1,x2)
temp=zeros(1,6);
Soogeno=zeros(49,4);
for i=1:length(RuleBase)
y=crisp(0,50,RuleBase(i,3),7);
temp(1,:)=RuleBase(i,:);
temp(1,3)=y;
Soogeno(i,:)=temp(1,1:4);
end
这是我的 python 代码:
def Mse(RuleBase,x1,x2):
temp=np.zeros(shape = (1,6))
soogeno=np.zeros(shape = (49,4))
for i in range(len(RuleBase)):
y=crisp(m=0,M=50,fy=RuleBase[i,3],n=7)
temp[0]=RuleBase[i]
temp[0,2]=y
Soogeno[i]=temp[0,0:3]
return(soogeno)
python 中严格执行缩进:
这应该 运行:
def Mse(RuleBase,x1,x2):
temp=np.zeros(shape = (1,6))
soogeno=np.zeros(shape = (49,4))
for i in range(len(RuleBase)):
y=crisp(m=0,M=50,fy=RuleBase[i,3],n=7)
temp[0]=RuleBase[i]
temp[0,2]=y
Soogeno[i]=temp[0,0:3]
return(soogeno)
我正在尝试将 MSE 函数从 Matlab 转换为 Python,但出现此错误:
for i in range(len(RuleBase)):
^
IndentationError: unexpected indent
我已经试过 space,除了白色 space 还有什么问题?
这是我在 matlab 中的函数:
function err=Mse(RuleBase,x1,x2)
temp=zeros(1,6);
Soogeno=zeros(49,4);
for i=1:length(RuleBase)
y=crisp(0,50,RuleBase(i,3),7);
temp(1,:)=RuleBase(i,:);
temp(1,3)=y;
Soogeno(i,:)=temp(1,1:4);
end
这是我的 python 代码:
def Mse(RuleBase,x1,x2):
temp=np.zeros(shape = (1,6))
soogeno=np.zeros(shape = (49,4))
for i in range(len(RuleBase)):
y=crisp(m=0,M=50,fy=RuleBase[i,3],n=7)
temp[0]=RuleBase[i]
temp[0,2]=y
Soogeno[i]=temp[0,0:3]
return(soogeno)
python 中严格执行缩进:
这应该 运行:
def Mse(RuleBase,x1,x2):
temp=np.zeros(shape = (1,6))
soogeno=np.zeros(shape = (49,4))
for i in range(len(RuleBase)):
y=crisp(m=0,M=50,fy=RuleBase[i,3],n=7)
temp[0]=RuleBase[i]
temp[0,2]=y
Soogeno[i]=temp[0,0:3]
return(soogeno)