ipython解释器

ipython magic

>>%lsmagic
Available line magics:
%alias  %alias_magic  %autocall  %autoindent  %automagic  %bookmark  %cat  %cd  %clear  %colors 
 %config  %cp  %cpaste  %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  %paste  %pastebin  %pdb  %pdef  %pdoc  %pfile  %pinfo  %pinfo2 
 %popd  %pprint  %precision  %profile  %prun  %psearch  %psource  %pushd  %pwd  %pycat  %pylab  
%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.

line magics 一个%开头
cell magics两个%开头
最后一行表示line magics可以不加%

使用whos查看当前变量空间

>>%whos
Variable   Type    Data/Info
----------------------------
n          int     3
name       int     3

使用reset重置当前空间变量

>>%reset
>>%whos
Interactive namespace is empty.

使用pwd查看当前文件夹

>>%pwd
Out[22]: '/home/lds'
>>%mkdir test                    # 创建文件夹
>>%cd test                        #改变当前文件夹目录
>>%%writefile hello.py            #写入文件
print("hello world")
>>%ls                                 #查看当前目录文件
>>%run hello.py                 #运行文件
>>import os
>> os.remove("hello.py")    #删除文件
>>%cd..
>> %rmdir   test                 #删除文件夹
>> %hist                            #查看历史命令                

ipython使用

使用?查看函数文档

>> sum?                                  #只显示文档
>>%pylab
Using matplotlib backend: Qt5Agg
Populating the interactive namespace from numpy and matplotlib
>>sort??                                   #显示文档和源代码

使用_ 得到上一次命令的输出结果

a = 12
a
_ + 13

使用!执行一些系统命令

>>!ping baidu.com
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值