如何在Python中返回文件的完整路径?

2024-05-14 11:09:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个类,它接受整个文件作为参数。 我需要以某种方式提取文件的完整路径

    class ATestCase(SuiteRule):
       def apply(self, suitefile):
           suitepath = ???The absolute path of suitefile???
           print(suitepath)

suitefile的确切类型是 <;类“rflint.parser.parser.SuiteFile”>


Tags: 文件theself路径parser参数def方式
1条回答
网友
1楼 · 发布于 2024-05-14 11:09:05

通过提供的附加信息(即suitfile是类rflint.parser.parser.SuiteFile并查看the source code-class SuiteFile继承自类RobotFile,因此suitefile.path将为您提供绝对路径(包括文件名)

相关问题 更多 >

    热门问题