如何从python中的文件名获取完整的文件路径?

问题描述 投票:0回答:1

我需要通过在python 2.7中提供文件名来获取文件的完整路径。不幸的是,我不允许使用pathlib模块。

 Example: 
filename: python.exe
full path that i want to print :  C:\app\tools\python27\python.exe

在此先感谢大家花点时间来回复。

python-2.7 path filenames filepath os.path
1个回答
0
投票

查看以下主题的线程:How do I get the full path of the current file's directory?

我不确定您如何在代码中实现此功能,但是“ pathlib”(适用于v3以上版本)和“ os”(适用于v3以下版本)库应该可以提供帮助。

很抱歉,如果您已经查看了该主题并且没有找到答案!

© www.soinside.com 2019 - 2024. All rights reserved.