首页 > 解决方案 > os.path.realpath() 返回一个以我家开头的字符串:

问题描述

os.path.realpath(__file__)

返回

/home/toto/file:/home/toto/.config/libreoffice/4/user/uno_packages/cache/uno_packages/lu37847ivic.tmp_/bal-L-1.1.4.oxt/python/rdt_bal.py

为什么它以 this 开头/home/toto/file:而不是给出预期的 url,它是 ':' 之后的部分?

标签: python

解决方案


os.path.realpath将首先解析路径中的任何符号链接,然后返回绝对路径


推荐阅读