+ 1

how to combine 100 list into one

i have 100 list, now i want to combine them into one. i know use list1+list2....,but this make me crazy. so is there any convenient way to make the job easier?

16th Apr 2020, 12:59 PM
odin king
5 Respuestas
+ 4
The question is: Where do these 100 lists come from? Are they stored in an external file? Or are they all defined in a python file?
16th Apr 2020, 3:00 PM
Lothar
Lothar - avatar
16th Apr 2020, 1:49 PM
Oma Falk
Oma Falk - avatar
+ 1
Lothar i crawl a website and using the following code:for i in range(100): url_i = 'http://www.haoshiwen.org/search.php?author=%E6%9D%8E%E7%99%BD&page=' + \ str(i) headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36'} r1 = requests.get(url=url_i, headers=headers) source = r1.content soup = BeautifulSoup(source, features='lxml') poems_link = soup.find_all('p')[0] # print(poems_link) poemLinks = [] for poem in poems_link: print(poem['href']) # try: # poemLinks.append('http://www.haoshiwen.org/' + poem['href']) # except BaseException: # pass # print(poemLinks)
17th Apr 2020, 12:06 AM
odin king
+ 1
when i run print(poemlinks ) ,which i hope to get a poemlinks list,but the output is 100 separated list.
17th Apr 2020, 12:08 AM
odin king