python生成list时获取list对象的消息内建方法append

2024-09-28 01:29:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图构建一个包含列表中第二个元素的列表。我首先抓取了一些链接并存储在links_2016

for i in links_2016:
    parsed = urlparse.urlparse(i)
    path = parsed[2] 
    pathlist = path.split("/")
    list_pathlist.append(pathlist)

#get the months
months = []
for i in range(0,44): #there are 44 elements in list_pathlist
    list_pathlist[i][2] #get the second element 
    months.append

但当我打印月份时,列表中会出现内置的方法消息:

^{pr2}$

在这之后,当我做print months时,我只得到[],这意味着结果有问题。在

我还需要计算月列表中的元素,所以我想学习如何解决这个问题。在


Tags: thepathin元素列表forget链接

热门问题