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 返回目标地址

相关文章:

  • 2022-12-23
  • 2021-12-07
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
猜你喜欢
  • 2021-09-12
  • 2022-12-23
  • 2021-11-17
  • 2021-12-17
  • 2021-08-17
  • 2021-10-06
  • 2021-08-24
相关资源
相似解决方案