making exe file from python that uses command line arguments

后端 未结 1 834
礼貌的吻别
礼貌的吻别 2020-11-30 12:12

I want to create an exe from a python script that uses command line arguments (argv)
From what I\'ve seen py2exe doesn\'t support command-line-arguments

What c

相关标签:
1条回答
  • 2020-11-30 12:26
    setup(console=['hello.py'])
    

    I believe the line you want to use looks like this.

    I tested this with 2 files:

    hello.py

    import sys
    
    for arg in sys.argv:
        print arg
    print "Hello World!"
    

    And setup.py

    from distutils.core import setup
    import py2exe
    
    setup(console=['hello.py'])
    

    I ran these commands:

    python setup.py py2exe
    

    And then in the dist folder, I ran this:

    hello.exe foo bar
    

    Result:

    hello.exe
    foo
    bar
    Hello World!
    
    0 讨论(0)
提交回复
热议问题