ipython
start
import numpy as np
导入numpy第三方库,起个别名np
# shift + tab # 查看方法参数
np.random.randint(4)
shift + tab
Docstring:
randint(low, high=None, size=None, dtype=‘l’)
Return random integers from low
(inclusive) to high
(exclusive).
魔法命令
运行外部python文件
%run *.py
当我们使用魔法命令执行了一个外部文件时,该文件的函数就能在当前会话中使用
运行耗时
%time statement
%timeit statement
%time一般用于耗时长的代码段
%timeit一般用于耗时短的代码段
查看当前会话中的所有变量与函数
%who
%whos
%who_ls
执行linux与windows命令
ls
!dir
- 查看更多魔法命令
%lsmagic
-
Available line magics:
%alias %alias_magic %autoawait %autocall %automagic %autosave %bookmark %cd %clear %cls %colors %config %connect_info %copy %ddir %debug %dhist %dirs %doctest_mode %echo %ed %edit %env %gui %hist %history %killbgscripts %ldir %less %load %load_ext %loadpy %logoff %logon %logstart %logstate %logstop %ls %lsmagic %macro %magic %matplotlib %mkdir %more %notebook %page %pastebin %pdb %pdef %pdoc %pfile %pinfo %pinfo2 %popd %pprint %precision %prun %psearch %psource %pushd %pwd %pycat %pylab %qtconsole %quickref %recall %rehashx %reload_ext %ren %rep %rerun %reset %reset_selective %rmdir %run %save %sc %set_env %store %sx %system %tb %time %timeit %unalias %unload_ext %who %who_ls %whos %xdel %xmode -
Available cell magics:
%%! %%HTML %%SVG %%bash %%capture %%cmd %%debug %%file %%html %%javascript %%js %%latex %%markdown %%perl %%prun %%pypy %%python %%python2 %%python3 %%ruby %%script %%sh %%svg %%sx %%system %%time %%timeit %%writefile
-