鍍金池/ 問答/Python/ 獲取到了67個列表頁,但是每個列表頁沒法單獨取出來?

獲取到了67個列表頁,但是每個列表頁沒法單獨取出來?

for page in range(1, 67):
    url_list = 'http://top.chinaz.com/hangye/index_news_{}.html'.format(page) #獲取列表頁鏈接
    # url_list1 = url_list.split()
    print(type(url_list))
    print(url_list)

輸出結(jié)果:

<class 'str'>
http://top.chinaz.com/hangye/index_news_1.html
<class 'str'>
http://top.chinaz.com/hangye/index_news_2.html
<class 'str'>
http://top.chinaz.com/hangye/index_news_3.html
<class 'str'>
http://top.chinaz.com/hangye/index_news_4.html
...
<class 'str'>
http://top.chinaz.com/hangye/index_news_67.html

我把獲取到的鏈接,都賦給了url_list。
打印一下url_list的內(nèi)容和類型。
請問,怎么從url_list里把每一個鏈接單獨取出來?因為我后面需要把每個鏈接都單獨打開。

回答
編輯回答
瘋浪

聽不懂你在說什么.

保存到數(shù)組就行了.

url_list = ['http://top.chinaz.com/hangye/index_news_{}.html'.format(page) for page in range(1, 67)]  
2017年12月1日 05:49
編輯回答
骨殘心
urls = []
for page in range(1, 67):
    # 獲取列表頁鏈接
    url = 'http://top.chinaz.com/hangye/index_news_{}.html'.format(page) 
    urls.append(url)
 print(type(urls))
 print(urls)

先多熟悉下python基本數(shù)據(jù)結(jié)構(gòu)的用法。

2018年3月5日 08:23