zoukankan      html  css  js  c++  java
  • 基本数据类型

    1、bytes

    2、string

    bytes类型转成string,直接使用decode()进行转化。

    1 byte_out = stdout.read()
    2 print(type(byte_out))
    3 print(byte_out)
    4 print(type(byte_out.decode()))
    5 print(byte_out.decode())
    View Code

    结果:

    <class 'bytes'>
    b'ens160    Link encap:Ethernet  HWaddr 00:50:56:99:a8:a2  
              inet addr:124.207.138.20  Bcast:124.207.138.31  Mask:255.255.255.240
              inet6 addr: fe80::250:56ff:fe99:a8a2/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:90175 errors:0 dropped:0 overruns:0 frame:0
              TX packets:39222 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:29697887 (29.6 MB)  TX bytes:8603589 (8.6 MB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:3423 errors:0 dropped:0 overruns:0 frame:0
              TX packets:3423 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1 
              RX bytes:209665 (209.6 KB)  TX bytes:209665 (209.6 KB)
    
    '
    <class 'str'>
    ens160    Link encap:Ethernet  HWaddr 00:50:56:99:a8:a2  
              inet addr:124.207.138.20  Bcast:124.207.138.31  Mask:255.255.255.240
              inet6 addr: fe80::250:56ff:fe99:a8a2/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
              RX packets:90175 errors:0 dropped:0 overruns:0 frame:0
              TX packets:39222 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000 
              RX bytes:29697887 (29.6 MB)  TX bytes:8603589 (8.6 MB)
    
    lo        Link encap:Local Loopback  
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host
              UP LOOPBACK RUNNING  MTU:65536  Metric:1
              RX packets:3423 errors:0 dropped:0 overruns:0 frame:0
              TX packets:3423 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1 
              RX bytes:209665 (209.6 KB)  TX bytes:209665 (209.6 KB)
    
    
    
    Process finished with exit code 0
  • 相关阅读:
    mysql重启.....
    tomcat双向认证
    tomcat单向认证
    tomcat ssi使用
    各种排序
    字符转换
    threeSum问题
    求出0~999之间的所有“水仙花数”并输出
    动态规划
    迷惑一天的代码
  • 原文地址:https://www.cnblogs.com/muyiyang/p/6901445.html
Copyright © 2011-2022 走看看