
- Jupyter 教程
- Jupyter - 首頁
- IPython
- IPython - 簡介
- IPython - 安裝
- IPython - 入門
- 執行和編輯 Python 指令碼
- IPython - 歷史命令
- IPython - 系統命令
- IPython - 命令列選項
- 動態物件內省
- IPython - IO 快取
- 將 IPython 設定為預設 Python 環境
- 匯入 Python Shell 程式碼
- IPython - 嵌入 IPython
- IPython - 魔法命令
- Jupyter
- Project Jupyter - 概述
- Jupyter Notebook - 簡介
- 使用 Jupyter 線上
- 安裝和入門
- Jupyter Notebook - 儀表盤
- Jupyter Notebook - 使用者介面
- Jupyter Notebook - 單元格型別
- Jupyter Notebook - 編輯
- Jupyter Notebook - Markdown 單元格
- 單元格魔法函式
- Jupyter Notebook - 繪圖
- 轉換 Notebook
- Jupyter Notebook - IPyWidgets
- QtConsole
- QtConsole - 入門
- QtConsole - 多行編輯
- QtConsole - 內聯圖形
- QtConsole - 儲存為 Html
- QtConsole - 多個控制檯
- 連線到 Jupyter Notebook
- 使用 github 和 nbviewer
- JupyterLab
- JupyterLab - 概述
- 安裝和入門
- JupyterLab - 介面
- JupyterLab - 安裝 R 核心
- Jupyter 資源
- Jupyter - 快速指南
- Jupyter - 有用資源
- Jupyter - 討論
IPython - 命令列選項
在本章中,讓我們瞭解如何在 IPython 中使用各種命令列選項。
呼叫 IPython 程式
您可以使用以下選項呼叫 IPython 程式:
C:\python36> ipython [subcommand] [options] [-c cmd | -m mod | file] [--] [arg]
檔案選項是一個帶有 .py 副檔名的 Python 指令碼。如果沒有給出其他選項,則執行指令碼並重新出現命令提示符。
C:\python36>ipython hello.py Hello IPython welcome to interactive computing
子命令和引數
IPython 命令接受以下子命令選項:
配置檔案 - 建立和管理 IPython 配置檔案。
核心 - 啟動一個沒有附加前端的核心。
定位 - 列印 IPython 目錄的路徑。
歷史記錄 - 管理 IPython 歷史記錄資料庫。
IPython 配置檔案子命令接受以下引數:
ipython profile create myprofile - 建立一個新的配置檔案。
ipython profile list - 列出所有可用的配置檔案。
ipython locate profile myprofile - 定位所需的配置檔案。
要安裝新的 IPython 核心,請使用以下命令:
Ipython kernel –install –name
要列印 IPython 目錄的路徑,請使用以下命令:
C:\python36>ipython locate myprofile C:\Users\acer\.ipython
此外,我們知道:
history 子命令管理 IPython 歷史記錄資料庫。
trim 選項將 IPython 歷史記錄資料庫縮減到最後 1000 個條目。
clear 選項刪除所有條目。
IPython 的一些其他重要命令列選項列在下面:
序號 | IPython 命令和描述 |
---|---|
1 | --automagic 開啟自動呼叫魔法命令。 |
2 | --pdb 在每次異常後啟用自動呼叫 pdb 偵錯程式。 |
3 | --pylab 預載入 matplotlib 和 numpy 以與預設的 matplotlib 後端進行互動式使用。 |
4 | --matplotlib 配置 matplotlib 以與預設的 matplotlib 後端進行互動式使用。 |
5 | --gui=options 啟用 GUI 事件迴圈與 ('glut', 'gtk', 'gtk2','gtk3', 'osx', 'pyglet', 'qt', 'qt4', 'qt5', 'tk', 'wx', 'gtk2', 'qt4') 中的任何一個整合。 |
一些 IPython 命令列選項的示例用法顯示在以下表格中:
序號 | IPython 命令和描述 |
---|---|
1 | ipython --matplotlib 啟用 matplotlib 整合 |
2 | ipython --matplotlib=qt 啟用使用 qt4 後端的 matplotlib 整合 |
3 | ipython --profile=myprofile 使用配置檔案 foo 啟動 |
4 | ipython profile create myprofile 使用預設配置檔案建立配置檔案 foo |
5 | ipython help profile 顯示配置檔案子命令的幫助 |
6 | ipython locate 列印 IPython 目錄的路徑 |
7 | ipython locate profile myprofile 列印配置檔案 `myprofile` 的目錄路徑 |