如何在Python上运行PyPi包命令

问题描述 投票:0回答:1

我想使用 PyPi 中的

twitch-dl
包。安装后,基本上是在终端上运行它,如下所示:

twitch-dl download <twitch-vod-url>

在终端上运行时效果很好,但我的目标是在我的 Python 脚本中运行此命令:

os.system('twitch-dl download <twitch-vod-url>`')

当我运行此代码时,我得到的只是

256
作为我的输出。它不下载任何东西。

python shell twitch os.system vod
1个回答
0
投票

你应该试试这个

import subprocess
import twitchdl...

vod_url = "<twitch-vod-url>"
command = f"twitch-dl download {vod_url}"

try:
    subprocess.check_output(command, shell=True)
    print("Download completed")
except subprocess.CalledProcessError as e:
    print(f"Download failed error code as {e.returncode}")
© www.soinside.com 2019 - 2024. All rights reserved.