这是我非常简单的代码,打印argvs:
import sys argv=sys.argv for each in sys.argv: print each这是运行时的输出:
e:\python>python test1.py 1 2 3 4 5 test1.py 1 2 3 4 5我希望它被编译,所以我用py2exe创建了一个:
e:\python>python setup.py py2exe和我的setup.py:
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 3}}, windows = [{'script': "test1.py"}], zipfile = None, )当我通过test1.exe 1 2 3 4 5或其他任何argvs运行我的程序时,我没有得到任何输出。 sys.argvs应该是一个至少包含一个对象(test1.exe)的列表,因此我认为我对python的打印函数有误解。 有什么我在这里做错了吗? 我只想把一切都打印到命令行。 我从Linux编程,但Windows用户应该使用我的程序。
非常感谢你
this is my very simple code, printing argvs:
import sys argv=sys.argv for each in sys.argv: print eachhere's the output when ran:
e:\python>python test1.py 1 2 3 4 5 test1.py 1 2 3 4 5I want it to be compiled, so I made one with py2exe:
e:\python>python setup.py py2exeand my setup.py:
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 3}}, windows = [{'script': "test1.py"}], zipfile = None, )and I don't get any output when I run my program by test1.exe 1 2 3 4 5 or with any other argvs. sys.argvs should be a list with at least one object(test1.exe) in it, therefore I think I have misunderstandings with print function of python. Is there anything I'm doing wrong here? I just want everything to be printed to commandline. I program from linux, but windows users should be using my program.
thank you very much
最满意答案
# ... windows = [{'script': "test1.py"}], #...windows选项用于创建GUI可执行文件,这会抑制控制台输出。 改用console :
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 3}}, console = [{'script': "test1.py"}], zipfile = None, ) # ... windows = [{'script': "test1.py"}], #...windows option is used to create GUI executables, which suppresses console output. Use console instead:
from distutils.core import setup import py2exe, sys, os sys.argv.append('py2exe') setup( options = {'py2exe': {'bundle_files': 3}}, console = [{'script': "test1.py"}], zipfile = None, )更多推荐
发布评论