安裝了wxpy,想做一個自動發送天氣預報的微信機器人,但是運行之后 一直反饋這樣的資訊,是哪里出現了問題,求詳細解答

uj5u.com熱心網友回復:
QR.png 是二維碼的圖片。出現''沒有應用程式.....'',說明系統關聯檔案失效。可能是沒下載完整, 也可能是你電腦里沒有打開這種文作格式的插件,
也有可能是你的python出了問題,也有可能是你的環境變數有問題
uj5u.com熱心網友回復:
請問如果是環境變數出現問題的話怎么解決,需要把wxpy和python 以及python檔案放在同一個檔案夾里嗎
uj5u.com熱心網友回復:
“沒有應用程式與此操作的程式有關聯 xxx.png”
-》說明os.startfile去嘗試呼叫系統默認程式去打開png圖片了,但是你(Windows)系統中,沒有找到默認可以打開png圖片的軟體。
-》你自己試試,Windows中資源管理器中,雙擊對應的你的 QQ.png圖片,能否有程式,比如 Windows中常見的默認的 圖片瀏覽器等軟體,去打開對應圖片
-》如果有,那就是代碼方面的問題
-》如果沒有,那就是你系統中本身就沒有可以打開png圖片的軟體
-》你自己下載一個其他能打開png圖片的軟體,即可。
附上:
os.startfile(path[, operation])
官網解釋:
os.startfile(path[, operation])?
Start a file with its associated application.
When operation is not specified or 'open', this acts like double-clicking the file in Windows Explorer, or giving the file name as an argument to the start command from the interactive command shell: the file is opened with whatever application (if any) its extension is associated.
When another operation is given, it must be a "command verb" that specifies what should be done with the file. Common verbs documented by Microsoft are 'print' and 'edit' (to be used on files) as well as 'explore' and 'find' (to be used on directories).
startfile() returns as soon as the associated application is launched. There is no option to wait for the application to close, and no way to retrieve the application's exit status. The path parameter is relative to the current directory. If you want to use an absolute path, make sure the first character is not a slash ('/'); the underlying Win32 ShellExecute() function doesn't work if it is. Use the os.path.normpath() function to ensure that the path is properly encoded for Win32.
To reduce interpreter startup overhead, the Win32 ShellExecute() function is not resolved until this function is first called. If the function cannot be resolved, NotImplementedError will be raised.
可用性: Windows。
uj5u.com熱心網友回復:
另外幫你(用google)搜python os.startfile 沒有應用程式與此操作的程式有關聯
找到了:
解決Python使用wxpy模塊登錄微信。就會拋出例外錯誤。_夏末班車博客-CSDN博客
里面有,和你一樣的問題,且給出了答案。
幫你整理如下:
"打開這個檔案C:\Users\Administrator\AppData\Local\Programs\Python\Python36-32\lib\site-packages\itchat\utils.py
匯入import webbrowser模塊,之后修改這段代碼,"
import webbrowser
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)
"然后運行登錄代碼,即可打開瀏覽器,然后關閉瀏覽器,掃描生成的二維碼圖片即可登錄成功。"
uj5u.com熱心網友回復:
對,謝謝您剛發的這些,現在確實可以打開瀏覽器 調出二維碼,但是掃碼登錄之后,還存在一個問題,python會回傳keyError:pass_ticket 無法登錄。我用兩個微信號都登不上去,這是為什么…轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/102343.html
