使用py2exe包进行转换。py2exe怎么装的可以网上另查。时间久了,记不太清了......
这个程序可以把自己进行转换。但是没法运行。。。。其实只要是需要修改自身的程序打包后都没法运行。
# -*- coding: utf- -*-
__author__ = "YuDian"
import os
var= if var==:
var=var+
with open(r'F:\python_codes\learn_python_of_simple_codes\demos\setup_auto.py','r+') as f:
flist=f.readlines()
flist[]='var=%s\n'%var
with open(r'F:\python_codes\learn_python_of_simple_codes\demos\setup_auto.py', 'w') as f:
f.writelines(flist)
if var==:
from distutils.core import setup
import os
import py2exe
setup(console=['setup_auto.py']) if var==:
var=var+
name=input('which function you want to pack?')
with open(r'F:\python_codes\learn_python_of_simple_codes\demos\setup_auto.py','r+') as f:
flist=f.readlines()
flist[]='var=%s\n'%var
flist[]=" setup(console=['%s'])\n"%name
with open(r'F:\python_codes\learn_python_of_simple_codes\demos\setup_auto.py', 'w') as f:
f.writelines(flist)
os.system('python setup_auto.py py2exe')
var=
with open(r'F:\python_codes\learn_python_of_simple_codes\demos\setup_auto.py','r+') as f:
flist=f.readlines()
flist[]='var=%s\n'%var
with open(r'F:\python_codes\learn_python_of_simple_codes\demos\setup_auto.py', 'w') as f:
f.writelines(flist)
每行对应的代码都不能改变。若是改变要把flist[3]='var=%s\n'%var和flist[16]的定位进行相应的更改。