码迷,mamicode.com
首页 > 其他好文 > 详细

基本数据类型

时间:2017-05-25 00:06:35      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:int   packet   pack   ror   oca   str   ons   multicast   finish   

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>
bens160    Link encap:Ethernet  HWaddr 00:50:56:99:a8:a2  \n          inet addr:124.207.138.20  Bcast:124.207.138.31  Mask:255.255.255.240\n          inet6 addr: fe80::250:56ff:fe99:a8a2/64 Scope:Link\n          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1\n          RX packets:90175 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:39222 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:1000 \n          RX bytes:29697887 (29.6 MB)  TX bytes:8603589 (8.6 MB)\n\nlo        Link encap:Local Loopback  \n          inet addr:127.0.0.1  Mask:255.0.0.0\n          inet6 addr: ::1/128 Scope:Host\n          UP LOOPBACK RUNNING  MTU:65536  Metric:1\n          RX packets:3423 errors:0 dropped:0 overruns:0 frame:0\n          TX packets:3423 errors:0 dropped:0 overruns:0 carrier:0\n          collisions:0 txqueuelen:1 \n          RX bytes:209665 (209.6 KB)  TX bytes:209665 (209.6 KB)\n\n
<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

 

基本数据类型

标签:int   packet   pack   ror   oca   str   ons   multicast   finish   

原文地址:http://www.cnblogs.com/muyiyang/p/6901445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!