Эти параметры хранятся в CSV-файле и открываются с помощью панд:
Код: Выделить всё
parameters = pd.read_csv('Parameters.csv')
Sound_list = parameters['Sound']
Text_list = parameters['Text']
Код: Выделить всё
for i in range(0,10):
n = range(0,len(Sound_list),1)
index = random.choice(n)
Sound_to_play = Sound_list.pop(index)
Text_to_show = Text_list.pop(index)
Код: Выделить всё
Traceback (most recent call last):
File "", line 4, in
Sound_to_play = Sound_list.pop(index)
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/generic.py", line 790, in pop
result = self[item]
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/series.py", line 871, in __getitem__
result = self.index.get_value(self, key)
File "/opt/anaconda3/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 4405, in get_value
return self._engine.get_value(s, k, tz=getattr(series.dtype, "tz", None))
File "pandas/_libs/index.pyx", line 80, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 90, in pandas._libs.index.IndexEngine.get_value
File "pandas/_libs/index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 997, in pandas._libs.hashtable.Int64HashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 1004, in pandas._libs.hashtable.Int64HashTable.get_item
KeyError: 0
Подробнее здесь: https://stackoverflow.com/questions/625 ... -in-a-loop
Мобильная версия