把.py檔編成.exe檔

要把已寫好的python編成exe檔
先下載py2exe

以上是安裝成功畫面

calender.py

#!/usr/bin/python
import os 
import calendar
import py2exe
cal = calendar.month(2017, 3)
print "Here is the calendar:"
print cal;
os.system('pause')

calendar 是月份模塊,可以用來顯示某個月份的月曆

setup.py

#!/usr/bin/python

from distutils.core import setup
import py2exe
setup(
    console = [{'script': 'calender.py'}]
)

執行編譯時:

編譯成功:

資料夾就多出build和dist這兩個資料夾

exe檔就會在dist資料夾裡