lb5645284 发表于 2018-8-15 07:10:27

python的list、tuple、dict、set的对比

d = { 'Adam': 95, 'Lisa': 85,'Bart': 59 }  print d.values()
  #
  for v in d.values():
  print v
  # 85
  # 95
  # 59
  或
  d = { 'Adam': 95, 'Lisa': 85, 'Bart':59 }
  print d.itervalues()
  # <dictionary-valueiterator object at 0x106adbb50>
  for v in d.itervalues():
  print v
  # 85
  # 95
  # 59
  或for key, value in d.items():
  ...   print key, ':', value
  ...
  Lisa : 85
  Adam : 95
  Bart : 59
页: [1]
查看完整版本: python的list、tuple、dict、set的对比