[Python] Python2.7发布成EXE
2018-03-21 16:50
447 查看
示例代码
代码来源:http://blog.csdn.net/summer_dew/article/details/79634944文件名:draw_line.py
# -*- coding: utf-8 -*- from PIL import Image from PIL import ImageDraw import os # input_img = r'E:\user\Desktop\tmp.png' input_img = raw_input("Enter the full path of the file:\n") input_color = raw_input("Enter grid color, separated by Spaces:\n") r,g,b = input_color.split(" ") r = int(r) g = int(g) b = int(b) (filepath,filename) = os.path.split(input_img) img = Image.open(input_img) img_d = ImageDraw.Draw(img) x_len, y_len = img.size x_step = x_len/50 y_step = y_len/30 for x in range(0, x_len, x_step): img_d.line(((x, 0), (x, y_len)), (r, g, b)) for y in range(0, y_len, y_step): j = y_len - y - 1 img_d.line(((0, j), (x_len, j)), (r, g, b)) img.save(os.path.join(filepath,"grid_"+filename) ) cnt = 1 for i in range(0,x_len,x_step): img_d.text((i,y_len-y_step), str(cnt).encode("utf8"),fill=(255,0,0)) cnt+=1 cnt = 1 for j in range(y_step,y_len,y_step): z = y_len - j img_d.text((0,z), str(cnt).encode("utf8"),fill=(255,0,0) ) cnt+=1 img.save(os.path.join(filepath, "grid_geocoding_"+filename)) print "compete" input()
PyInstaller
使用pip安装:pip2 install Pyinstallerpy2exe
下载安装py2exe:http://www.py2exe.org/编写代码
#!/usr/bin/python from distutils.core import setup import py2exe import os,sys CurrentPath = os.path.dirname(sys.argv[0]) setup(console=[str(CurrentPath)+'draw_line.py']) #filename
切换命名行,运行
cd C:\Python27\toExe python2 setup.py py2exe
生成结果:
exe结果:
相关文章推荐
- 手动实现把python项目发布为exe可执行程序过程分享
- python爬取百度图片---发布exe小计 编码是个大坑
- python3.6.3转化为win-exe文件发布
- Python:程序发布方式简介一(打包为可执行文件EXE)
- [转]手工将python程序发布为exe执行程序
- Python:程序发布方式简介一(打包为可执行文件EXE)
- 手工将python程序发布为exe执行程序
- 手工将python程序发布为exe执行程序 [转]
- 用PYTHON写一个应用程序并发布exe
- Python | 用Pyinstaller打包发布exe应用
- 用pyinstaller将Pythone 脚本生成EXE可执行文件发布
- 用Pyinstaller打包Python发布exe应用
- 手动实现把python项目发布为exe可执行程序过程分享
- 手动实现把python项目发布为exe可执行程序过程分享
- python2.7 windows dist,python 打包成exe
- 同时安装python2.7和Anaconda后python.exe和pip.py的区分
- Python2.7本地发布模块(modules)笔记
- 用PYTHON写一个应用程序并发布exe
- 【Python】将Python发布成exe
- 关于win7下python3.6.3发布.exe的那些破事