python3中string和bytes之间的转换
mystr = 'baidu.com'
print(type(mystr)) # <class 'str'>
mybyte = mystr.encode('utf-8')
print(type(mybyte)) # <class 'bytes'>
mybyte_str = mybyte.decode('utf-8')
print(type(mybyte_str)) # <class 'str'>
python3中string和bytes之间的转换
mystr = 'baidu.com'
print(type(mystr)) # <class 'str'>
mybyte = mystr.encode('utf-8')
print(type(mybyte)) # <class 'bytes'>
mybyte_str = mybyte.decode('utf-8')
print(type(mybyte_str)) # <class 'str'>