嘿所以有一天,我在乱搞一些代码,它给了我这个错误。Python |看到列表是否有元素时出现错误
if clearargs[1] == "history": \n IndexError: list index out of range
elif startswith(ui, "clear") or startswith(ui, "clr"):
clearargs = ui.split()
if len(clearargs) < 1:
refs.clearscr("Windows", os)
else:
if clearargs[1] == "history":
history = []
os.remove(hfilepath)
elif clearargs[1] == "exthistory":
extendedhistory = []
os.remove(ehfilepath)
BTW大多数功能都是自定义的
(这可能有助于重新访问关于序列“起源”的[文档](https://docs.python.org/3/library/stdtypes.html#sequence-types-list-tuple-range)。 ) – greybeard