获取某样东西里包含的东西
目前为止,已学到获取某样东西里包含的东西的三种方式
#方法一 字典的方式
>>> 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()

浙公网安备 33010602011771号