if "\\" in item["message"]:
item["message"] = str(item["message"]).replace("\\", "\\\\").encode("utf-8")
写程序,有许多“\”项[“消息”],因此,当试图插入此在MySQL表项,它的错误,我尝试应对项目[“消息”]的“\”,所以我写上面的程序,蟒:“” str中一个字节状物体是必需的,而不是“STR”
,当它运行时,它的错误:
Traceback (most recent call last):
File "C:/Python/PyCharmProject/FaceBookCrawl/FBCrawl.py", line 237, in <module>
group_download.group_feed_storage(FB_access_token,group_id,group_name)
File "C:\Python\PyCharmProject\FaceBookCrawl\group_download.py", line 116, in group_feed_storage
mysql_manage().group_feed_db_manage(type,group,name,feed)
File "C:\Python\PyCharmProject\FaceBookCrawl\database_manage.py", line 95, in group_feed_db_manage
if "\\" in item["message"]:
TypeError: a bytes-like object is required, not 'str'
Process finished with exit code 1
你能帮我一下吗?
什么是'type(item [“message”])? –