从使用命令行参数的python制作exe文件

Boa*_*oaz 5 python py2exe

我想从使用命令行参数的python脚本创建一个exe(argv)
从我看到的py2exe不支持命令行参数

我能做什么?

编辑:我使用的是GUI2Exe工具,所以我只是错过了控制台标志,但接受的答案是完全正确的

jgr*_*tty 22

setup(console=['hello.py'])
Run Code Online (Sandbox Code Playgroud)

我相信你想要使用的那条线看起来像这样.

我用2个文件测试了这个:

hello.py

import sys

for arg in sys.argv:
    print arg
print "Hello World!"
Run Code Online (Sandbox Code Playgroud)

和setup.py

from distutils.core import setup
import py2exe

setup(console=['hello.py'])
Run Code Online (Sandbox Code Playgroud)

我运行了这些命令:

python setup.py py2exe
Run Code Online (Sandbox Code Playgroud)

然后在dist文件夹中,我运行了这个:

hello.exe foo bar
Run Code Online (Sandbox Code Playgroud)

结果:

hello.exe
foo
bar
Hello World!
Run Code Online (Sandbox Code Playgroud)