Python在使用os包的過程中,經常遇到返回wen文件路徑的方法,那os.path.abspath()和os.path.realpath()的區別是什么呢,有時候傻傻分不清楚,現在我們就來用實例來說明下,他兩個的區別:
1.os.path.abspath()
-
返回一個目錄的絕對路徑
-
Return an absolute path.
-
-
'/etc/sysconfig/selinux'
-
-
'/root'
-
-
'/root/python_modu'
2.os.path.realpath()
-
返回指定文件的標准路徑,而非軟鏈接所在的路徑
-
Return the canonical path of the specified filename, eliminating any
-
symbolic links encountered in the path.
-
-
'/etc/selinux/config'
-
-
'/usr/bin/python2.7'
現在是不是一目了然,兄弟還不趕緊關注。
