jupyter巨好玩-簡介與安裝


ipython notebook改名jupyter了而且更好玩更好用

jupyter簡介

jupyter是啥啊?
這個要從ipython說起,ipython是個交互式的python的解釋器,自帶顏色,補全還有行號,科學界的很多大牛都用來進行數據分析和圖形顯示。

ipython還可以運行在瀏覽器上,就是下面這個樣子:

名字也就高大上一點,叫ipythoon notebook,那個jupyter圖標一開始就有的,現在升級改造了,不止於運行python,還有R,spark之類的高大上玩意兒。所以就直接用 jupyter來指代這一對產品了。

官方有個try頁面,可以玩一玩。

https://try.jupyter.org/

jupyter安裝

官方推薦的安裝是這個:http://jupyter.readthedocs.io/en/latest/install.html

Download Anaconda. We recommend downloading Anaconda’s latest Python 3 version (currently Python 3.5).
Download Anaconda. We recommend downloading Anaconda’s latest Python 3 version (currently Python 3.5).
Install the version of Anaconda, which you downloaded.
Install Jupyter using conda from the Terminal (Mac and Linux) or a Command Prompt window (Windows):
conda install jupyter
Congratulations. You have installed Jupyter Notebook. To run the notebook:
jupyter notebook

咱們民間可以直接安裝
如果已經有python環境:

直接pip install jupyter

如果沒有:
就先安裝個python環境,然后再裝

運行

jupyter notebook

然后就自動打開瀏覽器中localhost的8888端口,就可以在線寫代碼啦!不止於python,還有R等...

用戶界面和主要功能

  • 寫代碼
  • 寫文檔(cell類型就分成markdown和code,隨便改,所以我這文章都是直接寫出來的)
  • 科學運算和畫圖(numpy, scipy,pandas之類的以前都需要一個個安裝啊,現在全齊了)

示例代碼

4+6

10

這貨是個裝飾器

def show_output(func):
    def wrapped(*args, **kwargs):
        output = func(*args, **kwargs)
        print("the result is : ", output)
    return wrapped

def is_even(num):
    return num % 2 ==0

使用裝飾器運行函數,並輸出結果

f = show_output(is_even)
f(3)

the result is :  False

參考資源


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM