4. 获取当前的文件夹的路径,以及当前文件名的路径 os.path.realpath

使用os.path.realpath(__file__) 获得当前的文件夹的路径名, 使用os.path.split 进行路径切割

import os

src, _= os.path.split(os.path.realpath(__file__))
print(src, _)

算法效果

猜你喜欢

转载自www.cnblogs.com/my-love-is-python/p/11018524.html