python to exe转换部分代码

时间:2013-05-31 09:12:35

标签: exe py2exe python-2.x

非常好,任何人都知道我是否可以在脚本中制作exe单段代码,例如:

一个文件(hello.py):

print('hello word')

def exit():
    print('good bye')

两个文件(setup.py):

from distutils.core import setup
import py2exe
import sys
import hello


if len(sys.argv) == 1:
    sys.argv.append("py2exe")
    sys.argv.append("-q")


options = {
    #"bundle_files": 1,
    "dll_excludes": ["w9xpopen.exe"] # we don't need this
    }

setup(name = "python",
    description = "aplicacion python",
    version = "1.0",
    console = [
        {
            "script":"hello.exit()",
            #"icon_resources": [(0, "res_python.ico")]
        }
    ],
    options = {"py2exe": options},
    zipfile = None,

    )

为了更好的解释,我从同一个文件创建了exe,谢谢。

2 个答案:

答案 0 :(得分:0)

文件setup.py:

from distutils.core import setup
import py2exe
import sys
import shell

main = shell.shell()

if len(sys.argv) == 1:
    sys.argv.append("py2exe")
    sys.argv.append("-q")


options = {
    #"bundle_files": 1,
    "dll_excludes": ["w9xpopen.exe"] # we don't need this
    }

setup(name = "python",
    description = "aplicacion python",
    version = "1.0",
    console = [
        {
            "script":"main.conexion()",
            #"icon_resources": [(0, "res_python.ico")]
        }
    ],
    options = {"py2exe": options},
    zipfile = None,

    )

空闲回应:

运行py2exe 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ build 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ build \ bdist.win32 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ build \ bdist.win32 \ winexe 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ build \ bdist.win32 \ winexe \ collect-2.7 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ build \ bdist.win32 \ winexe \ bundle-2.7 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ build \ bdist.win32 \ winexe \ temp 创建C:\ Documents and Settings \ francisco \ Escritorio \ programas python \ mis_proyectos \ shell reverse \ dist 搜索所需的模块

答案 1 :(得分:0)

在实现实体蛇高清之前曾经使用Python试试破坏python文件。