如何清除PyQt5中的Cookie? 我尝试了以下代码:
QWebEngineCookieStore.deleteAllCookies()
我得到一个错误:
TypeError: deleteAllCookies(self): first argument of unbound method must have type 'QWebEngineCookieStore'
我添加了花括号:
QWebEngineCookieStore().deleteAllCookies()
但是又出现了错误:
TypeError: PyQt5.QtWebEngineCore.QWebEngineCookieStore cannot be instantiated or sub-classed
答案 0 :(得分:0)
无法创建QWebEngineCookieStore,您需要做的是从QWebEngineProfile获取它,如下所示:
QWebEngineProfile.defaultProfile().cookieStore().deleteAllCookies()