Jupyter

1 ) 魔法命令

1.1 ) 执行外部文件

%run add.py

3

add(2, 3)

5

1.2 ) 运行计时

%time print("hello word")
hello word
CPU times: user 68 µs, sys: 20 µs, total: 88 µs
Wall time: 93.9 µs
%timeit print("hello word")

1.3 ) 查看当前会话中的所有变量与函数

%who

Interactive namespace is empty.

%whos

Interactive namespace is empty.

%who-ls

No variables match your requested type.

1.4 ) 运行终端命令

!ls
add.py     test.ipynb

1.5 ) 查看魔法指令

lsmagic
Available line magics:
%alias  %alias_magic  %autocall  %automagic 
%autosave  %bookmark  %cat  %cd  %clear  %colors  %config  %connect_info  %cp  %debug  %dhist  %dirs  %doctest_mode  %ed  %edit  %env  %gui  %hist  %history  %killbgscripts  %ldir  %less  %lf  %lk  %ll  %load  %load_ext  %loadpy  %logoff  %logon  %logstart  %logstate  %logstop  %ls  %lsmagic  %lx  %macro  %magic  %man  %matplotlib  %mkdir  %more  %mv  %notebook  %page  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2  %popd  %pprint  %precision  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  %qtconsole  %quickref  %recall  %rehashx  %reload_ext  %rep  %rerun  %reset  %reset_selective  %rm  %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  %%debug  %%file  %%html  %%javascript  %%js  %%latex  %%markdown  %%perl  %%prun  %%pypy  %%python  %%python2  %%python3  %%ruby  %%script  %%sh  %%svg  %%sx  %%system  %%time  %%timeit  %%writefile
Automagic is ON, % prefix IS NOT needed for line magics.
posted @ 2018-02-18 12:48  漫威查尔斯  阅读(200)  评论(0编辑  收藏  举报