包括一个 json 文件与 exe pyins

2024-05-05 13:52:55 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经读了好几个小时了。我无法理解如何使用资源资源选项

上面写着

-r RESOURCE, --resource RESOURCE

Add or update a resource to a Windows executable. The RESOURCE is one to four items, FILE[,TYPE[,NAME[,LANGUAGE]]]. FILE can be a data file or an exe/dll. For data files, at least TYPE and NAME must be specified. LANGUAGE defaults to 0 or may be specified as wildcard * to update all resources of the given TYPE and NAME. For exe/dll files, all resources from FILE will be added/updated to the final executable if TYPE, NAME and LANGUAGE are omitted or specified as wildcard *.This option can be used multiple times.

我不明白文件[,类型[,名称[,语言]]]是什么意思。这是我使用的命令

pyinstaller test.py -F -r=test.json

应该是吗测试.json[,JSON[,test]]?在

谢谢。在


Tags: orandtonametesttypeupdatebe
1条回答
网友
1楼 · 发布于 2024-05-05 13:52:55

我不确定你是否还需要帮助,但这应该会帮助未来从谷歌来到这里的人。使用第一次在py脚本上运行pyinstaller时生成的spec文件。从那里你可以添加json和其他数据文件,如下所示

 # -*- mode: python -*-

block_cipher = None

added_files = [
         ( 'configREs.json', '.'),  # Loads the '' file from
                                    # your root folder and outputs it with
                                    # the same name on the same place.
         ]


a = Analysis(['gui.pyw'],
             pathex=['D:\\OneDrive\\Programming\\Python Projects\\Python'],
             binaries=[],
             datas=added_files,
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          exclude_binaries=True,
          name='name here',
          debug=False,
          strip=False,
          upx=True,
          console=False, icon='iconname.ico', version='version.rc' )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=False,
               upx=True,
               name='gui')

相关问题 更多 >