python string和bytes string和int bytes和list互换

1. string and bytes

byte_type_data.decode()	#bytes转str
str_type_data.encode()    #str转bytes
#注必要的时候可以在encode或者decode里面加'utf-8'

2. string and int

str(int_type_data) # int转化为十进制string
hex(int_type_data) # int转化为十六进制string
int(str_type_data,10)#将10进制表示的string转int
int(str_type_data,16)#将16进制表示的string转int

3.bytes and list

from gmssl import func
func.bytes_to_list(bytes_type_data)#bytes转list
func.list_to_bytes(bytes_type_data)#list转bytes

你可能感兴趣的:(编程)