python3-Django运行报错TypeError: a bytes-like object is required, not 'str'
python3提示:a bytes-like object is required,not 'str'
源代码:
for k in cats:
if binascii.crc32(k) == n:
return k
运行错误:TypeError: a bytes-like object is required, not
str
错误原因:从字面意思已经说明是“需要一个字节类型的数据,而不是一个String类型”,反复找了才发现是我使用send()发送数据时候不能直接填写字符串,需要转成字节类型才行。
格外说下:encode()
decode()两个方法的使用encode()是可以将String类型的数据转化成字节类型的。而decode()是将字节型转化为String类型里面带参数字符偏码。
解决办法:
for k in cats:
if binascii.crc32(k.encode()) == n:
return k
把I′d like a tin of pork.改为复数I′d like ()()().括号里应该 其他 2020-05-14 …
I’d like a doll as my birthday present.改为一般疑问句 ( 英语 2020-05-16 …
I'd like a mask as my birthday present.( 改否定句) 英语 2020-05-16 …
i'd like a bike as my birthday present 对画线部分提问 英语 2020-05-16 …
I'd like a book as a birthday present 对 a book as 英语 2020-05-16 …
L'd like a story book 改成一般疑问句 英语 2020-05-16 …
i 'd like a pair of shoes.i like this pair ,can i 英语 2020-05-16 …
六年级英语填空和根据中文意思完成句子1.I‘d like a ( )of a( ).(动物面具)2 英语 2020-05-16 …
i‘d like a (square)cake.对括号提问( )shape of cake ( ) 英语 2020-05-17 …
we"d like a small pizza ___ ____ _____(带有青椒)and o 英语 2020-05-17 …