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」])? –