python中os.path.abspath與os.path.realpath 區別
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'
>>>
os.path.realpath 返回的是使用軟鏈的真實地址
os.path.abspath 返回目標地址