[問題] expect pywintypes.error不能用已刪文
def click7 ():
try:
win32api.ShellExecute(0, 'open', 'C:\Program Files (x86)\KONICA
MINOLTA\FTP Utility\KMFtp.exe', '', '', 1) # 執行程式
except pywintypes.error:
win32api.ShellExecute(0, 'open', 'D:\guangfucode\FTPUtilitySetup',
'', '', 1) # 安裝程式
想說如果電腦有KMFtp.exe直接執行 如果沒有則安裝FTP
但還是出現
Exception in Tkinter callback
Traceback (most recent call last):
File "D:\Anaconda3\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
File "C:/Users/user/.spyder-py3/temp.py", line 20, in click6
win32api.ShellExecute(0, 'open', 'd:\Desktop\clean', '', '', 1) # 執行
程式
pywintypes.error: (2, 'ShellExecute', '系統找不到指定的檔案。')
為何pywintypes.error expect無法偵測呢
而就算把expect pywintypes.error: 改成 expect: 捕捉所有錯誤 還是不行
請教各位何解?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 117.56.227.246 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1566638879.A.FC3.html
※ 編輯: gogogo123 (117.56.227.246 臺灣), 08/24/2019 17:45:38
Python 近期熱門文章
PTT數位生活區 即時熱門文章