Dictionary popitem,dictionarypopitem,#The popitem
Dictionary popitem,dictionarypopitem,#The popitem
#The popitem method is similar to list.pop. Unlike list.pop, however, popitem pops #off a random item because dictionaries don't have a 'last element' or any order #whatsoever. This may be very useful if you want to remove and process the items one #by one in an efficient way (without retrieving a list of the keys first):d = {'url': 'http://www.python.org', 'spam': 0, 'title': 'Python Web Site'}print d.popitem()print d#Although popitem is similar to the list method pop, there is no dictionary #equivalent of append. Because dictionaries have no order, such a method wouldn't #make any sense.
- Difference between zip and map,differencebetween,S1 =
- String Output Width and Precision,outputprecision,from
- Sorting a list.,sortinglist,aList = [ 2,
- Display one item through an index,displayitem,inventor
- Nested function: 3 levels,nestedlevels,def f1():
- Strings can be subscripted (indexed),subscriptedindexe
热门文章:
相关内容
- Difference between zip and map,differencebetween,S1 = 'abc'S2
- String Output Width and Precision,outputprecision,from math im
- Sorting a list.,sortinglist,aList = [ 2,
- Display one item through an index,displayitem,inventory =
- Nested function: 3 levels,nestedlevels,def f1():
- Strings can be subscripted (indexed),subscriptedindexed,#like in C,
- Bit calculation: shift left,bitcalculation,x = 1
- 1 is true in Python,truepython,if 1: pr
- Loop through a file,loopthroughfile,f=open('/tmp
- Redirecting stdout and stderr Output,redirectingstdout,import sys p
评论关闭