如何解决python中的list index out of range。

该部分代码。
            response=session.get(url)

            code=re.findall('charset=(.*?)"',response.text)[0]

            content=response.text


            # 文件的ID
            doc_id=re.findall('view/(.*?).html',url)[0]
            
            # 文件类型
            #types=re.findall(r"docType.*?:.*?'(.*?)'",content)[0]
            
            # 文件主题(目前支持TXT·doc·PDF·PPT·xls表格文件)
            #title=re.findall(r"title.*?:.*?'(.*?)'",content)[0]

            if types=='txt':
                md5sum=re.findall('"md5sum":"(.*?)",',content)
                if md5sum!=[]:
                    result=parse_txt2(content,code,doc_id)
                    title=re.findall(r'<title>(.*?). ',content)[0]
                    #filename=os.getcwd()+"\\Files\\"+title+'.txt'
                    filename=path+"\\"+title+".txt"
                    save_file(title,filename,result)
                else: 
                    result=parse_txt1(code,doc_id)
                    title=re.findall(r"title.*?:.*?'(.*?)'",content)[0]
                    #filename=os.getcwd()+"\\Files\\"+title+'.txt'
                    filename=path+"\\"+title+".txt"
                    save_file(title,filename,result)
            elif types=='doc':
                title=re.findall(r"title.*?:.*?'(.*?)'",content)[0]
                result=parse_doc(content)
                filename=path+"\\"+title+".doc"
                save_file(title,filename,result)
            elif types=='pdf':
                title=re.findall(r"title.*?:.*?'(.*?)'",content)[0]
                result=parse_pdf(content)
                filename=path+"\\"+title+".txt"
                save_file(title,filename,result)
            elif types=='ppt':
                    title=re.findall(r"title.*?:.*?'(.*?)'",content)[0]
                    parse_ppt1(doc_id,title)

            elif types=='xls':
                title=re.findall(r"title.*?:.*?'(.*?)'",content)[0]
                result=parse_xls(content)
                filename=path+"\\"+title+".txt"
                save_file(title,filename,result)

        except Exception as e:
            print(e)


if __name__=='__main__':
    main()

麻烦了,谢谢。

最好能修改好发出来。

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 以帮助更多的人 ^-^