python os.path.abspath realpath 区别

python os.path.abspath realpath 区别
#home
cd /home
mkdir a
mkdir b
touch a/1.txt
ln -s /home/a/1.txt /home/b/1.txt
python
进入实时模式
>>> import os
>>> os.path.abspath("a/1.txt")
'/root/a/1.txt'
>>> os.path.abspath("b/1.txt")
'/root/b/1.txt'
>>> os.path.realpath("b/1.txt")
'/root/a/1.txt'
>>> os.path.realpath("a/1.txt")
'/root/a/1.txt'
>>>
 
realpath 返回的是 使用软链 的真实地址
abspath 返回目标地址
原文地址:https://www.cnblogs.com/YingxuanZHANG/p/8819110.html