ten_things = 'apples oranges crpws telephone light sugar'
print 'wait there\'s not ten things in the list, let\' fix it.'
stuff = ten_things.split(' ')
more_stuff = ['day','night', 'song', 'feisee', 'corn', 'nanana', 'girl', 'boy']
while len(stuff) != 10:
next_one = more_stuff.pop()
print"adding:", next_one
stuff.append(next_one)
print"there's %d items now."%len(stuff)
print stuff
print"let's do some things with stuff"
print stuff[1]
print stuff[-1]#whoa fancy. the output value is 'corn'
print stuff.pop()
print ' '.join(stuff) #what
print '#'.join(stuff[3:5]) #super stelar
- 关于 类class 与面向对象的编程 相对与面向函数的编程 (class应该是个与function相对的概念)
- dir()可用表现出现在模组的 所有函数变量类 dir(thing) 表现出thing的 所有函数变量类