code/pyinstaller_sys.py

10 lines
313 B
Python
Raw Permalink Normal View History

2024-09-26 18:01:24 +08:00
import sys
import os
def get_path(relative_path):
try:
base_path = sys._MEIPASS # pyinstaller打包后的路径
except AttributeError:
base_path = os.path.abspath(".") # 当前工作目录的路径
return os.path.normpath(os.path.join(base_path, relative_path)) # 返回实际路径