pyinstaller打包成exe之后,获取exe路径
文件路径 C:\Users\寒寻\Documents\gamefi\createNewETHAddress\createNewETHAddress.py
print(os.path.realpath(sys.argv[0]))
C:\Users\寒寻\Documents\gamefi\createNewETHAddress\createNewETHAddress.py
print(os.path.realpath(sys.executable))
C:\ProgramData\Anaconda3\envs\gamefi\python.exe
print(os.path.dirname(os.path.realpath(sys.argv[0])))
C:\Users\寒寻\Documents\gamefi\createNewETHAddress
print(os.path.dirname(os.path.realpath(sys.executable)))
C:\ProgramData\Anaconda3\envs\gamefi
如果直接使用__file__,在打包成exe之后是无法获取文件路径的