Get the directory where the EXE file is located after python is packaged
After the exe is packaged, the directory obtained using the following code is incorrect
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
Get the directory where the exe is located
import os
import sys
BASE_DIR = os.path.dirname(os.path.realpath(sys.executable))
dir_path = os.path.join(BASE_DIR, 'data')
Get the parameters of the exe file
import os
import sys
os.path.dirname(os.path.realpath(sys.argv[0]))