ipython的用法详解

本文介绍了如何使用pip命令安装ipython,一个增强版的Python交互式命令行工具。安装完成后,通过命令提示符启动ipython,体验其独特的in/out提示符及tab自动补全功能。文章还展示了如何在ipython中执行系统命令,如查看当前目录、返回上级目录等。

ipython是一个升级版的交互式python命令行工具.

ipython安装

pip install ipython

等到命令执行完成后显示successfully表示完装成功

在命令提示符下输入ipython就可以启动ipython了

 

其与原版python命令行工具不同在于ipython的提示符变成了in和out.

 

in为输入命令的地方,out为命令执行完成后输出的地方

 

ipython的特点

tab键自动补全一些常用的方法

 

支持一些系统命令

    In [2]: pwd             # 显示当前所在目录
    Out[2]: '/root'
    
    In [3]: cd ..           # 返回当前目录的上一级目录
    /   
   

执行系统命令(!)

    In [6]: !ifconfig
    ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
            inet 192.168.81.10  netmask 255.255.255.0  broadcast 192.168.81.255
            inet6 fe80::a545:8b99:d507:4d0f  prefixlen 64  scopeid 0x20<link>
            ether 00:0c:29:95:d5:31  txqueuelen 1000  (Ethernet)
            RX packets 12851  bytes 9887304 (9.4 MiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 7172  bytes 1546188 (1.4 MiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
            inet 127.0.0.1  netmask 255.0.0.0
            inet6 ::1  prefixlen 128  scopeid 0x10<host>
            loop  txqueuelen 1  (Local Loopback)
            RX packets 140  bytes 12132 (11.8 KiB)
            RX errors 0  dropped 0  overruns 0  frame 0
            TX packets 140  bytes 12132 (11.8 KiB)
            TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
    
    In [7]: !ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
        link/ether 00:0c:29:95:d5:31 brd ff:ff:ff:ff:ff:ff
        inet 192.168.81.10/24 brd 192.168.81.255 scope global ens33
           valid_lft forever preferred_lft forever
        inet6 fe80::a545:8b99:d507:4d0f/64 scope link 
           valid_lft forever preferred_lft forever
    
    In [8]: !cat /etc/sysconfig/selinux
    
    # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    #     enforcing - SELinux security policy is enforced.
    #     permissive - SELinux prints warnings instead of enforcing.
    #     disabled - No SELinux policy is loaded.
    SELINUX=disabled
    # SELINUXTYPE= can take one of three two values:
    #     targeted - Targeted processes are protected,
    #     minimum - Modification of targeted policy. Only selected processes are protected. 
    #     mls - Multi Level Security protection.
    SELINUXTYPE=targeted 

转载于:https://www.cnblogs.com/leading-net/p/10526002.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值