os.path

作者: 樊海鹏 | 来源:发表于2018-04-09 10:29 被阅读0次
import os

_basedir = os.path.abspath(os.path.dirname(__file__))
print os.path.join(_basedir, 'wdio.conf.js')
print os.path.join(_basedir, '../README.md')
print os.getcwd()
del os
/home/fhp/test/app/wdio.conf.js
/home/fhp/test/app/../README.md
/home/fhp/test/app

其实_basedir 相当于 pwd

大致就是, 先确定根文件的绝对路径,
然后由此, 去确定其他文件的绝对路径

相关文章

网友评论

      本文标题:os.path

      本文链接:https://www.haomeiwen.com/subject/wkaphftx.html