加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

pyinstaller 生成单一的EXE文件之后获取当前目录的方法

发布时间:2020-12-13 22:14:10 所属栏目:百科 来源:网络整理
导读:使用如下命令查看当前文件目录 print __file__ print os .path.realpath(__file__) print 'using sys.executable:' ,repr( os .path.dirname( os .path.realpath(sys.executable))) print 'using sys.argv[0]:' ,repr( os .path.dirname( os .path.realpath(

使用如下命令查看当前文件目录

print __file__
        print os.path.realpath(__file__)
        print 'using sys.executable:',repr(os.path.dirname(os.path.realpath(sys.executable)))
        print 'using sys.argv[0]:',repr(os.path.dirname(os.path.realpath(sys.argv[0]   )))
        print sys.argv[0]
        print sys.path[0]

在工程文件中运行的结果

E:PycharmProjectsuntitledtest.py
E:PycharmProjectsuntitledtest.py
using sys.executable: 'D:Program Files (x86)Python27'
using sys.argv[0]: 'D:Program Files (x86)JetBrainsPyCharm Community Edition 4.5.3helperspycharm'
D:Program Files (x86)JetBrainsPyCharm Community Edition 4.5.3helperspycharmutrunner.py
E:PycharmProjectsuntitled

使用Pyinstaller生成一个单一的EXE文件之后的结果

E:PycharmProjectsuntitled> disttest.exe
C:UsersABCAppDataLocalTemp_MEI66522ApoManager.pyc
C:UsersABCAppDataLocalTemp_MEI66522ApoManager.pyc
using sys.executable: 'E:PYCHAR~1untitleddist'
using sys.argv[0]: 'E:PYCHAR~1untitleddist'
E:PYCHAR~1untitleddisttest.exe
C:UsersABCAppDataLocalTemp_MEI66522

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读