获取某样东西里包含的东西

目前为止,已学到获取某样东西里包含的东西的三种方式

#方法一 字典的方式

>>> Person ={

...     "张三":176,

...     "李四":180,

...     "王五":191

...     }

>>> print Person["张三"]

176

 

#方法二 模块的方式

#this goes in mystuff.py

def apple():

  print "I am an apple"

#然后调用模块

import mystuff

mystuff.apple()

 

#方法三 类的方式

class Fruit:

  def apple():

    print "I am an apple"

thing = Fruit()

thing.apple()

 

posted @ 2017-01-30 20:50  道高一尺  阅读(135)  评论(0)    收藏  举报