我编写了一个程序来遍历文件夹的文件,并将“.jpg”文件扩展名添加到所有文件中,而没有任何文件扩展名。我在我的电脑上测试了这个程序,到目前为止它可以工作。我使用 auto-py-to-exe 包将 .py 文件编译为 .exe 文件,以将程序发送给她的计算机上没有安装 python 的朋友。当我测试 .exe 文件时,我发现程序的行为不同并且不再工作。以下代码是我写的,如果你取消注释打印命令你可以在运行 .py 和 .exe 文件时看到不同的文件
import os
files = os.listdir(os.path.dirname(os.path.abspath(__file__)))
for file in files:
# print(file)
split_tup = os.path.splitext(file)
if split_tup[1] == '':
os.rename(file, file + '.jpg')
# The input is just that the console doesn't shut down
a = input()
对于 auto-py-to-exe,我使用了以下命令:
pyinstaller --noconfirm --onefile --console "C:/mypath/jpg_wizard.py"
有没有办法可以更改 auto-py-to-exe 命令/设置或替代代码,以便能够将程序作为 .exe 文件运行并获得与 .py 文件相同的结果?