嘿所以有一天,我在亂搞一些代碼,它給了我這個錯誤。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