简单Python实例,以及打包成.exe文件
来源:互联网 发布:c语言学习网站 编辑:程序博客网 时间:2024/06/06 05:15
1、工具准备:
我的Python版本是python 3.x的
打包工具:cxfreeze,我的是 windows 32bit的 http://sourceforge.net/projects/cx-freeze/files/4.3.2/
关联你的eclipse:
help->install new solftware->输入插件地址:http://download.aptana.com/studio3/plugin/install, 访问download.aptana.com/studio3会提示叫你把前面的地址输入到下面的work with 框中。
选中,然后一路next 下去。
安装成功之后, window->preferences->pyDev图片下面的最后一项,关联安装的python.exe
然后创建python的project呗:
写了一个简单的例子:
'''
Created on 2014-7-4
@author: liyao
'''
import os
oldWorld = None
newWorld = None
fileType = None
# scan the path you entered, then replace aim files
def scanDir(path, oldWorld, newWorld, fileType):
for root, dirs, files in os.walk(path):
for filespath in files:
if os.path.join(root, filespath).endswith("."+fileType):
replaceFun(os.path.join(root, filespath), oldWorld, newWorld)
# replace the old world as the new world
def replaceFun(filepath, oldWorld, newWorld):
lines = open(filepath, "r", encoding= "utf-8").readlines()
fp = open(filepath, "w")
for s in lines:
fp.write(s.replace(oldWorld, newWorld))
fp.close
flag = None
while 1:
print("==================================================")
print("====== 0、退出当前应用 =======")
print("====== 1、进入当前应用 =======")
print("====== =======")
print("==================================================")
flag = input("编号:")
if flag == "0":
print("谢谢使用")
break
elif flag == "1":
dir = input("enter your project,like:E:\python\Hellowin path=")
if not dir.strip():
print("is null dir")
exit(-1)
oldWorld = input("enter your old string =")
if not oldWorld.strip():
print("is null world")
exit(-1)
newWorld = input("enter your new string =")
if not newWorld.strip():
print("is null world")
exit(-1)
fileType = input("enter your file type,like:java,txt,xml type= ")
if not fileType.strip():
print("is null world")
exit(-1)
scanDir(dir, oldWorld, newWorld, fileType)
打包:
1、安装cxfreeze
2、C:\Python33\Scripts的目录下面会有的,安装它,会自动匹配到你的python安装文件路径下面。
把命令转到对应Scripts下面,才能执行cxfreeze的命令:
找到你的.py文件,通过命令:
如:cxfreeze C:\Python33\Scripts\Project.py --target-dir E:\然后会生成.exe等相关文件,这样打包就成功了:
参考:
http://huangda-hd.blog.163.com/blog/static/81808426201361741158158/
- 简单Python实例,以及打包成.exe文件
- python文件打包成exe
- python打包成exe文件
- 将python程序打包成exe文件
- python通过py2exe打包成exe文件
- python程序打包成exe执行文件
- 将python程序打包成.exe文件
- 将python程序打包成exe文件
- Python的py文件打包成exe
- Python:程序打包exe文件
- python打包生成exe文件
- Python打包为exe文件
- python打包成exe
- Python 打包成 EXE
- python打包成exe
- Python打包成exe
- python 打包成EXE
- python打包成exe
- Eclipse自动换行
- WiFi共享精灵陪你看《爸爸去哪儿》
- 公交部署wifi热点,是否需要?
- PCD(点云数据)文件格式
- java保留两位小数5种方法
- 简单Python实例,以及打包成.exe文件
- linux -- FTP配置详解
- 流量劫持 —— 浮层登录框的隐患
- ROCK介绍
- java:SEVERE: IOException while loading persisted sessions: java.io.EOFException
- POJ 1328 Radar Installation
- 用"再生龙"Clonezilla 来克隆Linux系统
- 闻名遐迩JavaScript库总结
- angular——sportsStore项目的问题与解决