

jupyter是一种交互式计算和开发环境的笔记,ipython命令行比原生的python命令行更加友好和高效,还可以运行web版的界面,支持多语言,输出图形和excel等功能。
一、安装
pip3 install --upgrade pip
pip3 install jupyter
二、使用命令行
进入命令界面
ipython

ipython强大功能介绍
1.tab键补全功能

2.快速查看文档,函数名+问号?可以查看文档,类似原生python的help函数

3.运行shell命令
感叹号!+shell直接运行shell命令,如!pwd

4.运行python文件
%run python文件路径
5.强大的魔术方法
例如,查看函数的运行时间
%time a = np.arange(1000)

列出所有的魔术命令
%lsmagic
常用魔术方法介绍
%quickref 显示IPython的快速参考
%magic 显示所有魔术命令的详细文档
%debug 从最新的异常跟踪的底部进入交互式调试器
%hist 打印命令的输入(可选输出)历史
%pdb 在异常发生后自动进入调试器
%paste 执行剪贴板中的Python代码
%cpaste 打开一个特殊提示符以便手工粘贴待执行的Python代码
%reset 删除interactive命名空间中的全部变量/名称
%page OBJECT 通过分页器打印输出OBJECT
%run script.py 在IPython中执行一个Python脚本文件
%prun statement 通过cProfile执行statement,并打印分析器的输出结果
%time statement 报告statement的执行时间
%timeit statement 多次执行statement以计算系综平均执行时间。对那些执行时 间非常小的代码很有用
%who、%who_ls、%whos 显示interactive命名空间中定义的变量,信息级别/冗余度可变
%xdel variable 删除variable,并尝试清除其在IPython中的对象上的一切引用
三、运行web版的ipython
jupyter notebook
或
ipython notebook
运行界面如下,如果8888端口没有占用,会自动打开
http://localhost:8888/tree

命令行有的网页版都有,命令行没有的网页版也有,例如
多语言的代码显示,如markdown、Go、Java、Nginx、MySQL啥的
支持终端,在线直接使用命令行
支持直接操作文件
渲染媒体文件,如图片、视频、音乐
网页版强大功能简单介绍
1.渲染图片、音乐、视频
渲染图片示例
from IPython.display import Image
Image(filename="/Users/chenqionghe/Downloads/light-weight.jpg")

2.直接显示绘制的图形
直接在网页显示绘制的图形,命令行就达不到这样的效果了,爽!
import numpy as np
import matplotlib.pyplot as plt
x = np.array([1,2,3,4,5,6,7,8])
y = np.array([3,5,7,6,2,6,10,15])
plt.plot(x,y,'r')# 折线 1 x 2 y 3 color
plt.plot(x,y,'g',lw=10)# 4 line w
# 折线 饼状 柱状
x = np.array([1,2,3,4,5,6,7,8])
y = np.array([13,25,17,36,21,16,10,15])
plt.bar(x,y,0.2,alpha=1,color='b')# 5 color 4 透明度 3 0.9
plt.show()

3.载入代码
%load /Users/chenqionghe/test.py

4.常用快捷键
执行当前cell,并自动跳到下一个cell:Shift Enter
执行当前cell,执行后不自动调转到下一个cell:Ctrl-Enter
为一行或者多行添加/取消注释:Crtl /
打开帮助,Ctrl+Shirt+P
界面这东西小伙伴们可以自己去点使用一下,很简单就上手了,绝对python开发者的福音,high起来吧~
*声明:本文于网络整理,版权归原作者所有,如来源信息有误或侵犯权益,请联系我们删除或授权事宜。

觉得不错,点个“在看”然后转发出去