这我的文件结果,但是我在命令行直接运行命令的时候,或是在别的地方调用脚本的时候,总是找不到文件?
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) print (os.path.join(BASE_DIR,"排名.xls")) df = read_excel(os.path.join("排名.xls"))
这个脚本不行~~在当前目录下是可以的,但是 退一级目录就不行了
欢迎选择我的课程,让我们一起见证您的进步~~
I didn’t realize you used 2os.path.dirname嘛?BASE_DIR 为/百度覆盖率,而"排名.xls"的路径在/百度覆盖率/官网业务词目录下,os.path.join(BASE_DIR,"排名.xls")Of course they don’t exist
os.path.dirname
/百度覆盖率
/百度覆盖率/官网业务词
os.path.join(BASE_DIR,"排名.xls")
It is estimated that if you are using Python2 on the windows platform, you will have this problem with Chinese file names
It is recommended to upgrade Python3 to solve...
I didn’t realize you used 2
os.path.dirname
嘛?BASE_DIR 为/百度覆盖率
,而"排名.xls"的路径在
/百度覆盖率/官网业务词
目录下,os.path.join(BASE_DIR,"排名.xls")
Of course they don’t existIt is estimated that if you are using Python2 on the windows platform, you will have this problem with Chinese file names
It is recommended to upgrade Python3 to solve...