英文:
ZeroDivisionError: division by zero (osu learning)
问题
无法修复该错误。我尝试在Google上查找,但没有找到解决方法。
英文:
I cant fix that error
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
Cell In[17], line 1
----> 1 data_files = osulearn.dataset.all_files(OSU_FOLDER, verbose=True)
3 if not os.path.exists('.data'):
4 os.makedirs('.data')
File c:\Users\danil\OneDrive\Desktop\OsuLearn-master\OsuLearn-master\osulearn\dataset.py:41, in all_files(osu_path, limit, verbose)
39 for i in range(len(replays)-1, -1, -1):
40 if verbose:
---> 41 _print_progress_bar(replays, i, reverse=True)
43 beatmap = _get_replay_beatmap_file(osu_path, replays[i])
45 if beatmap is None:
File c:\Users\danil\OneDrive\Desktop\OsuLearn-master\OsuLearn-master\osulearn\_cli.py:4, in _print_progress_bar(collection, index, bar_width, buffer_width, reverse)
1 def _print_progress_bar(collection, index, bar_width=40, buffer_width=80, reverse=False):
2 bar_format = "\r[{done}>{todo}] {text}"
----> 4 progress = index / (len(collection) - 1)
5 if reverse:
6 progress = 1 - progress
ZeroDivisionError: division by zero
I dont know how to fix it, i tried to find in google but nothing found
答案1
得分: 0
直接部分 len(collection) - 1
是表达式的一部分,如果集合的大小为1,它会导致 ZeroDivisionError。您需要增加集合的大小(大于一个项目),然后一切都会正确。
英文:
It seems that the expression
progress = index / (len(collection) - 1)
directly part this part len(collection) - 1
in case that collection has size 1, it generates ZeroDivisionError.
You have to increate sice of collection (> one item) and all will be correct.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论