天天看點

ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any()...

ValueError: The truth value of a DataFrame is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all()

錯誤原因是Nexcel是dateframe類型,但我使用os.path.realpath(Nexcel) 擷取其路徑報錯。

Nexcel = pd.DataFrame()  # 隻是一個圓括号的話說明建立的資料表是空的
ExcelName = filepath + '/{}.xlsx'.format(tempfilename + '拆分' + self.leix + self.sheet_name)#Excel儲存位置
Nexcel.to_excel(ExcelName)  # 調用to_excel 方法
os.path.realpath(Nexcel)