Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/google-app-engine/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 函数在特定行后不工作:Pylint表示;“不可检查代码”;_Python_Pandas - Fatal编程技术网

Python 函数在特定行后不工作:Pylint表示;“不可检查代码”;

Python 函数在特定行后不工作:Pylint表示;“不可检查代码”;,python,pandas,Python,Pandas,我试图将一个函数应用于多个文件,但我根本无法从该函数获得输出,pylint说代码是不可检查的 这是我当前的代码: path = str(askdirectory()) for metric in metrics: corner = pd.read_excel(f'{path}/{metric} - TOP LEFT CELL.xlsx') metricFrame(corner) 到目前为止,代码工作正常,但在函数内部没有任何功能: def metricFrame(corner

我试图将一个函数应用于多个文件,但我根本无法从该函数获得输出,pylint说代码是不可检查的

这是我当前的代码:

path = str(askdirectory())

for metric in metrics:
    corner = pd.read_excel(f'{path}/{metric} - TOP LEFT CELL.xlsx')
    metricFrame(corner)
到目前为止,代码工作正常,但在函数内部没有任何功能:

def metricFrame(corner,top,left,filling): 

    # # Extract Top Left Corner Metric from TOP LEFT files  
    topleft = corner.iloc[0]['A']    
    return topleft 
    print(corner) # This is the line that pylint highlights as unreacheable

“返回”导致功能停止运行或中断?为什么会发生这种情况?

return
退出该函数。将
print()
语句放在
return

之前,将
print(角落)
移动到
return top left
之前。
return
调用结束函数。

在return之前粘贴打印是,
return
将是函数中执行的最后一条语句。它就是这样做的。
return
“返回”函数的值,因此结束它。它永远不会到达代码,pylint在这里的暗示是正确的。翻译将永远无法到达代码
print(corner)
,因为您返回的时间早于此。