Python IndexError: tuple index out of range

 def _requests_(self,title_list,link_list,time_list,args):

        for num in range(0,len(time_list)):
             -sharp
             -sharp sql="select id  from news_source where publishTime=%s and link=%s ;"%(time_list[num],link_list[num])
             -sharp self.cursor.execute(sql)
             -sharp account_result = self.cursor.fetchone()
             -sharp if account_result ==None:
                 result = requests.get(
                     "https://project.test.ethercap.com/spider/news/save-source?title={}&link={}&logo={}&publishTime={}&source={}".format(
                         title_list[num], link_list[num], time_list[num], args))
                 time.sleep(2)
                 print (result)
                 
                 

I passed 3 lists, but reported an error, ask for advice, thank you

Traceback (most recent call last):
File "36kr.py", line 502, in < module >

kr().get_36kr_content()

File "36kr.py", line 78, in get_36kr_content

self._requests_(title_list, link_list, time_list, "36kr")

File "36kr.py", line 490, in requests

title_list[num], link_list[num], time_list[num], args))

IndexError: tuple index out of range

Mar.22,2021

there are five {} in the format string, but you passed four parameters.

In [1]: "{}{}".format(1)
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-1-47f9e2ea3532> in <module>()
----> 1 "{}{}".format(1)

IndexError: tuple index out of range

that's it. Be careful, my friend.

Menu