尝试使用for循环在不同列表中附加str值。以下是我的反感请帮我解决这个问题。
directors_1 = [] directors_2 = [] directors_3 = [] directors_4 = []
director = dict()
for director_no in range(0, 4):
if container.find_all('p')[2].find_all('a', href=True)[director_no]['href'][-11:] == 'adv_li_dr_'+str(director_no):
director[director_no+1] = (container.find_all('p')[2].find_all('a', href=True)[director_no].text).strip()
d = director[1]
"directors_" + str(director_no+1).append(d) #Problem with this line
else:
"directors_" + str(director_no+1).append('NA')