基本数据类型

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了基本数据类型相关的知识,希望对你有一定的参考价值。

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

 

以上是关于基本数据类型的主要内容,如果未能解决你的问题,请参考以下文章

c_cpp Robolution基本代码片段

在代码片段中包含类型转换

Unity中Shader的三种基本类型

在Android中将数据从基本活动发送到片段[重复]

html PHP代码片段: - AJAX基本示例:此代码演示了使用PHP和JavaScript实现的基本AJAX功能。

对这个带有 & 不带 = 的代码片段返回类型感到非常困惑