- バイナリタイプ/バイト(バイト)
バイト(データ)バイナリタイプ変換print(bytes(10)) # b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' print(bytes('abc',encoding='utf-8')) # b'abc' print(bytes([1,2,3])) # b'\x01\x02\x03',列表中的元素必须是整数 # 字符串.encode str1='hello' b1=str1.encode(encoding='utf-8') print(b1) # b'hello' # 二进制转字符串 b1=b"[100,99,'98']" str1=str(b1,encoding='utf-8') print(str1) # "[100,99,'98']" print(eval(str1)) # [100,99,'98'] # 二进制数据.decode(encoding="utf-8") b2=b'hello' str2=b2.decode(encoding='utf-8') print(str2) # hello
入場から刑務所へ-バイナリ変換
おすすめ
転載: blog.csdn.net/weixin_44628421/article/details/109194124
おすすめ
ランキング