在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python IndexError: tuple index out of r

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)):
             #
             # sql="select id  from news_source where publishTime=%s and link=%s ;"%(time_list[num],link_list[num])
             # self.cursor.execute(sql)
             # account_result = self.cursor.fetchone()
             # 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)
                 
                 

我傳遞的3個列表,但是報錯,求指教,謝謝

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

回答
編輯回答
歆久

format字符串里有5個{},但是你傳了4個參數(shù).

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

就這樣.細心點朋友.

2017年10月26日 04:38