如何提取網址中的文件名

u = urllib2.urlopen(addr)this

data = u.read()url


splitPath = addr.split('/')spa

fName = splitPath.pop()ci

print fNamerem


就是這樣,我也不會,不事後來看到list.pop()就搞定了it


list.pop([i]) io

Remove the item at the given position in the list, and return it. If no index is specified, a.pop() removes and returns the last item in the list. (The square brackets around the i in the method signature denote that the parameter is optional, not that you should type square brackets at that position. You will see this notation frequently in the Python Library Reference.)ast

相關文章
相關標籤/搜索