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.youkuaiyun.com/gukesdo/article/details/7101684
获取当前路径的Python函数
本文提供了一个Python函数,用于获取当前文件的绝对路径。该函数首先检查当前路径是否为文件,如果是,则返回其目录路径;否则,返回调用者文件的绝对路径。

被折叠的 条评论
为什么被折叠?



