python學習筆記----01、Python的安裝

來源:互聯網
上載者:User

標籤:運行   license   bsp   edit   檔案   contain   右鍵   ice   python指令碼   

Python安裝windows
1234567 1、下載安裝包    https://www.python.org/downloads/2、安裝    預設安裝路徑:C:\python273、配置環境變數    【右鍵電腦】--》【屬性】--》【進階系統設定】--》【進階】--》【環境變數】--》【在第二個內容框中找到 變數名為Path 的一行,雙擊】 --> 【Python安裝目錄追加到變值值中,用 ; 分割】    如:原來的值;C:\python27,切記前面有分號

linux、Mac

123 無需安裝,原裝Python環境  ps:如果內建2.6,請更新至2.7

  

五、Hello World程式

在linux 下建立一個檔案叫hello.py,並輸入

1 print("Hello World!")

然後執行命令:python hello.py ,輸出

123 localhost:~ lei$ vim hello.pylocalhost:~ lei$ python hello.pyHello World!

指定解譯器

上一步中執行 python hello.py 時,明確的指出 hello.py 指令碼由 python 解譯器來執行。

如果想要類似於執行shell指令碼一樣執行python指令碼,例: ./hello.py ,那麼就需要在 hello.py 檔案的頭部指定解譯器,如下:

123 #!/usr/bin/env python  print "hello,world"

如此一來,執行: ./hello.py 即可。

ps:執行前需給予 hello.py 執行許可權,chmod 755 hello.py

在互動器中執行 

除了把程式寫在檔案裡,還可以直接調用python內建的互動器運行代碼, 

123456 localhost:~ lei$ pythonPython 2.7.10 (default, Oct 23 2015, 18:05:06)[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwinType "help", "copyright", "credits" or "license" for more information.>>> print("Hello World!")Hello World!

python學習筆記----01、Python的安裝

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.