IPython简明教程

四个重要的Help

两种模式:命令模式及编辑模式。 用Esc切换至命令模式,用Enter切换至编辑模式。

Magic functions

Line magics: 以%开头 Cell magics: 以%%开头


In [1]:
lists = [i for i in range(5)]
lists?

%timeit range(1000)


100000 loops, best of 3: 6.49 µs per loop

In [5]:
%lsmagic


Out[5]:
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  %%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.

In [ ]:
%run test_run.py

In [1]:
!iPython profile locate default


/Users/weixi/.ipython/profile_default

In [2]:
ls /Users/weixi/.ipython/profile_default


db/                       ipython_kernel_config.py  security/
history.sqlite            log/                      startup/
ipython_config.py         pid/

In [4]:
from IPython.lib import passwd
my_psss = passwd('weixi')
my_psss


Out[4]:
'sha1:89a3f0ccfb1b:769802f294cbb05b18db3a28180fdf54222fe190'

In [2]:
%who


Interactive namespace is empty.