ITeye博客

python获取执行路径的方法

fishyych · 2012-11-19 16:47 · dynamic language · 编程语言 · Markdown

def current_path():  
    path=os.path.realpath(sys.path[0])  
    if os.path.isfile(path):  
        path=os.path.dirname(path)  
        return os.path.abspath(path)  
    else:  
        caller_file=inspect.stack()[1][1]  
        return os.path.abspath(os.path.dirname(caller_file))  

 

 

 

http://blog.csdn.net/gukesdo/article/details/7101684

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。