热线电话:13121318867

登录
2019-02-19 阅读量: 870
python如何将Byte对象转换为String

同样,Decoding是将Byte对象转换为String的过程。它使用decode()实现。如果您知道使用哪种编码对字节字符串进行编码,则可以将字节字符串解码回字符串。编码和解码是过程。

# Python code to demonstate Byte Decoding

# initialising a String

a = 'GeeksforGeeks'

# initialising a byte object

c = b'GeeksforGeeks'

# using decode() to decode the Byte object

# decoded version of c is stored in d

# using ASCII mapping

d = c.decode('ASCII')

# checking if c is converted to String or not

if (d==a):

print ("Decoding successful")

else : print ("Decoding Unsuccessful")

0.0000
0
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子