syw20170419
#获取到当前文件的上个文件夹目录
ABSPATH = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))

#获取的是相对路径
FRONTEND = os.path.abspath(os.path.join(ABSPATH, sys.argv[0]))
print ABSPATH
print FRONTEND

#获取的是相对路径
print sys.argv[0]


结果:

/Users/lucky/PycharmProjects/lucky_L/test_02
/Users/lucky/PycharmProjects/lucky_L/test_02/test.py
/Users/lucky/PycharmProjects/lucky_L/test_02/test.py

 

分类:

技术点:

相关文章: