这我的文件结果,但是我在命令行直接运行命令的时候,或是在别的地方调用脚本的时候,总是找不到文件?
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"))
这个脚本不行~~在当前目录下是可以的,但是 退一级目录就不行了
PHPz2017-04-18 10:28:29
I didn’t realize you used 2os.path.dirname
嘛?BASE_DIR 为/百度覆盖率
,
而"排名.xls"的路径在/百度覆盖率/官网业务词
目录下,os.path.join(BASE_DIR,"排名.xls")
Of course they don’t exist
怪我咯2017-04-18 10:28:29
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...