读不了excel解决方案,在py脚本里添加如下)
import osimport sys# 获取当前目录def resource_path(relative_path):# Get absolute path to resource, works for dev and for PyInstaller current_path os.path.dirname(os.path.realpath(sys.argv[0]))return os.path.join(current_path, relative_path)print(resource_path(sample.xlsx)) ## ----- 打印一下看看是否在临时文件夹下搜索data pd.read_excel(resource_path(sample.xlsx)) ## 读取固定目录下的excel