我想為我的項目創建一個自動更新程序,它從互聯網下載并安裝文件。我已經完成了如何使用所需名稱將文件下載到所需位置。我卡住的地方是如何安裝該文件。到目前為止我寫的代碼:from urllib.request import urlretrieveimport getpassurl = 'https://sourceforge.net/projects/artigence/files/latest/download'print('File Downloading')usrname = getpass.getuser()destination = f'C:\\Users\\{usrname}\\Downloads\\download.exe'download = urlretrieve(url, destination)print('File downloaded')該文件被下載到我的下載文件夾中?,F在,如何使用 python 安裝 .exe 文件?
1 回答

SMILET
TA貢獻1796條經驗 獲得超4個贊
您將需要使用該subprocess模塊來執行.exe文件。
import subprocess
cmd = "{download location} batch.exe"
returned_value = subprocess.call(cmd, shell=True)? # returns the exit code in unix
print('returned value:', returned_value)
我強烈建議不要用于pyautogui此目的。
添加回答
舉報
0/150
提交
取消