python ichat使用學習記錄


1.OSError: [WinError -2147221003] 找不到應用程序: 'D:\\python\\ichat\\qrcode.jpg'

原因是該庫中沒有windows系統如何打開二維碼圖片的處理方法

解決問題的辦法,詳細的內容可參考 【https://blog.csdn.net/qq_21349669/article/details/78873193

解決方法:
http://www.iplaypy.com/wenda/wd19142.html
打開這個文件C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\itchat\utils.py
導入import webbrowser模塊,之后找到 def print_qr(fileDir):模塊,修改這段代碼,

def print_qr(fileDir):
if config.OS == 'Darwin':
subprocess.call(['open', fileDir])
elif config.OS == 'Linux':
subprocess.call(['xdg-open', fileDir])
elif config.OS == 'Windows':
#subprocess.call(['cmd', fileDir])
#os.startfile(fileDir)
webbrowser.open(fileDir)
else:
os.startfile(fileDir)

然后運行登錄代碼,即可打開瀏覽器,然后關閉瀏覽器,掃描生成的二維碼圖片即可登錄成功。

 2.itchat.search_chatrooms()函數返回的列表值查詢不到群聊,原因是:未將群聊保存到通訊錄中。

測試時,發現有的時候能夠發送群聊信息,結果有時發送不出去。因為未保存到通訊錄中,只是臨時的話,只有群聊信息正活躍時,才會獲取到列表


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM