裝:
下載,從這里下載:http://python.org/download/
下載windows版本,下載完成以后,雙擊打開,然后一步一步安裝。
*Python 2.5.2 Windows installer
下載地址:
http://python.org/ftp/python/2.5.2/python-2.5.2.msi
115:python
(Windows binary -- does not include source)
裝好后,啟動 Python command line,然后輸入:print "Hello World"
如果輸出"Hello World",那就表明安裝成功了。
簡單的配置:
右鍵我的電腦-屬性-高級-環境變量,在path里輸入你的python安裝位置即可,比java簡單的多了。
我的是 E:\Python25;應該是找到pythonw.exe的父一級目錄。
測試:
隨便建一個文件夾,如在d\code\python下建立一個文本文件,並改名為 hello.py
在文本中輸入
print "Hello World"
在命令提示符下進入到 d\code\python路徑下
1、輸入python hello.py
2、直接輸入hello.py (必須設置環境變量才可以)
程序將會輸出Hello World
我們看另一個稍微復雜的程序:
integer1=raw_input("enter the first integer:\n")
integer1=int(integer1)
integer2=raw_input("enter the second integer:\n")
integer2=int(integer2)
sum=integer1+integer2
print "The sum is ",sum
另存為sum.py .
(注:raw_input是內建函數要求用戶輸入。integer1=int(integer1)將integer1轉換成整型。)
執行結果為:
E:\>python e:\python\sum.py
enter the first integer:
8
enter the second integer:
11
The sum is 19
完