在python中制作列表时获取列表对象的消息内置方法append
我试图构建一个列表,其中包含列表中的第二个元素。我首先抓取了一些链接并存储在links_2016中 但当我打印月份时,我会在列表中得到内置的方法消息:在python中制作列表时获取列表对象的消息内置方法append,python,list,Python,List,我试图构建一个列表,其中包含列表中的第二个元素。我首先抓取了一些链接并存储在links_2016中 但当我打印月份时,我会在列表中得到内置的方法消息: '06' <built-in method append of list object at 0x103c85170> '06' <built-in method append of list object at 0x103c85170> '06' <built-in method append of list ob
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
'06'
<built-in method append of list object at 0x103c85170>
之后,当我打印月份时,我只得到[],这意味着结果有问题
我还需要计算月份列表中的元素,因此我想了解如何解决这个问题。希望现在可以
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,len(list_pathlist)): #there are 44 elements in list_pathlist
months.append(list_pathlist[i][2]) #you are actually getting the third item
#since list indice start at 0, if you want the second item do [1]
print(months)
要计算“月份”列表中的元素,请执行“月份”
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,len(list_pathlist)): #there are 44 elements in list_pathlist
months.append(list_pathlist[i][2]) #you are actually getting the third item
#since list indice start at 0, if you want the second item do [1]
print(months)