IndexError: list index out of range in PyCharm

Mithilesh
import subprocess
import sys

video_link, threads = sys.argv[1], sys.argv[2]
subprocess.call([
   "youtube-dl",
    video_link,
   "--external-downloader",
   "aria2c",
   "--external-downloader-args",
   "-x"+threads
])

Whenever I run the code the following error pops up. Help me please

_link, threads = sys.argv[1], sys.argv[2]

IndexError: list index out of range

Prayson W. Daniel

You are most likely missing the arguments.

When you run,

python myscript.py arg1 arg2

sys.argv is a list with myscript.py at sys.argv[0],arg1 at sys.argv[1], etc

So consider using if conditions or try-except to check if we have necessary arguments to unpack:

import subprocess
import sys

if len(sys.argv)>2:

    myscript.pyvideo_link, threads = sys.argv[1], sys.argv[2]
    subprocess.call([
   "youtube-dl",
    video_link,
   "--external-downloader",
   "aria2c",
   "--external-downloader-args",
   "-x"+threads
])

else:
    print('Missing Video link and thread arguments')
    #raise Error if desired

Эта статья взята из Интернета, укажите источник при перепечатке.

Если есть какие-либо нарушения, пожалуйста, свяжитесь с[email protected] Удалить.

Отредактировано в
0

я говорю два предложения

0обзор
Войти в системуУчаствуйте в комментариях

Статьи по теме

Почему я получаю «IndexError: list index out of range» во время цикла for, на полпути красивого парсинга супа?

Почему эта программа выдает ошибку IndexError: list index out of range, но только иногда

IndexError: list index out of range python 3.6

Keras ImageGenerator : IndexError: list index out of range

IndexError: list index out of range for loop in python

IndexError: list index out of range in Reversal of arrays

Python IndexError: list index out of range when using a list as an iterable

.split() function giving IndexError: list index out of range with beautifulsoup

IndexError: list index out of range in if else when condition matches

Python web scrapping "IndexError: list index out of range"

How to fix "IndexError: list index out of range" in Python?

Python: IndexError: list index out of range happens in some case only

Python: IndexError: list index out of range with randint function

IndexError: list index out of range when checking matrix contents

.rsplit() | return empty string instead of `IndexError: list index out of range`

How can I fix IndexError: list index out of range in Python?

Python 3 - IndexError: string index out of range

Вложенный цикл, используемый в коде поиска hcf в Python, возвращает IndexError: index out of range

IndexError: list index out of range. Trying to create a list of dictionaries for BeatifulSoup items

Ошибка «List index is out of range» для доступа к атрибуту в следующем макете

有空列表時如何解決“IndexError at / list index out of range”

How to fix "IndexError: list index out of range" in micropython socket.getaddrinfo() method?

Python - ERROR: lib_type = fields[4] IndexError: list index out of range

Error: IndexError: string index out of range. Trying to reverse the order of a list

IndexError: list index out of range when assigning values to tuples from a for loop

fake_useragent module not connecting properly - IndexError: list index out of range

Python - ERROR: lib_type = fields[4] IndexError: list index out of range

IndexError: list index out of range. Can anyone help me out with this Python code ? Includes concepts of numpy and pandas

list index out of range - списки Python с одним элементом

TOP список

  1. 1

    Распределение Рэлея Curve_fit на Python

  2. 2

    В типе Observable <unknown> отсутствуют следующие свойства из типа Promise <any>.

  3. 3

    Merging legends in plotly subplot

  4. 4

    TypeError: store.getState não é uma função. (Em 'store.getState ()', 'store.getState' é indefinido, como posso resolver esse problema?

  5. 5

    ContentDialog.showAsync в универсальном оконном приложении Win 10

  6. 6

    PayPal REST API возвращает INVALID_CURRENCY_AMOUNT_FORMAT

  7. 7

    Невозможно отобразить данные модели загрузки Spring в Thymeleaf

  8. 8

    FormsAuthentication.SignOut () не работает после изменения CookieDomain

  9. 9

    Перебирайте несколько столбцов в фрейме данных Panda и находите уникальные значения подсчета

  10. 10

    Does addListener in JavaFX get garbage collected when the ChangeListener is typed as a lambda?

  11. 11

    Définition de la valeur par défaut dans le dictionnaire Python si la clé est manquante

  12. 12

    How to click an array of links in puppeteer?

  13. 13

    Cannot find reference System

  14. 14

    Android Включение / выключение вспышки камеры программно с помощью Camera2

  15. 15

    Как добавить Swagger в веб-API с поддержкой OData, работающий на ASP.NET Core 3.1

  16. 16

    How to set windows.form's start position to bottom?

  17. 17

    Добавить URL-адрес скрипта в очередь: поместить переменную в URL-адрес

  18. 18

    Разделить набор на несколько наборов Scala

  19. 19

    Интеграция Jenkins + Jfrog через плагины - в опубликованном банке добавлена метка времени (дата)

  20. 20

    Unable to open a new window from a method

  21. 21

    Запуск sqlplus в фоновом режиме в Unix

популярныйтег

файл