【发布时间】:2018-05-15 15:23:36
【问题描述】:
list_1 包含一个 URL 列表。加入字符串和列表后,输出如下所示:
"http://www.imdb.com['/title/tt2338151/?pf_rd_m=A2FGELUUNOQJNL&pf_rd_p=3376940102&pf_rd_r=0Z7H698B14B7XQ2ERWGA&pf_rd_s=center-1&pf_rd_t=15506&pf_rd_i=top_tt_2']p="
我不想在其中包含 [' 和 ]。下面是我正在使用的代码。
for links in list_1:
new=links
new_link='http://www.imdb.com'+str(links)
list_2.append(new_link)
print(list_2)
【问题讨论】:
-
而不是 new=links 使用 links=links[2:len(links)-2]
-
使用
"".join(links)而不是str(links)
标签: python python-3.x