Last active
April 29, 2019 08:29
-
-
Save wjzhangq/1fffd9f823900de8dc89579b85b32480 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cur_file_dir(): | |
# 获取脚本路径 | |
path = sys.path[0] | |
# 判断为脚本文件还是py2exe编译后的文件,如果是脚本文件,则返回的是脚本的目录,如果是py2exe编译后的文件,则返回的是编译后的文件路径 | |
if os.path.isdir(path): | |
return path | |
elif os.path.isfile(path): | |
return os.path.dirname(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment