# -*- coding : utf-8 -*-
ten_things = "Apples Oranges Crows Telephone Light Sugar"

print "Wait there's not 10 things in that list, let's fix that."

stuff = ten_things.split(' ') # split(ten_things, ' ')
more_stuff = ["Day", "Night", "Song", "Frisbee", "Corn", "Banana", "Girl", "Boy"]

while len(stuff) != 10:
    next_one = more_stuff.pop()
    print "Adding:", next_one
    stuff.append(next_one)  # append(stuff, next_one)
    print "There's %d items now." % len(stuff)
    
print "There we go: ", stuff

print "Let's do some things with stuff."

print stuff[1] 
print stuff[-1] #whoa! fancy  (-1)是基数
print stuff.pop()
print ' '.join(stuff) # what? cool! 用空格来连接stuff的各个元素
print '#'.join(stuff[3:5]) # super stellar 用#来连接

————————————————————————————————————————————————————————————————————————————————————

1.某些使用处理句点(. )的函数如

  a.pop() <=> pop(a) #pop仅有一个参数,此处为a

  b.split(' ') <=> split(b, ' ') #split有两个参数

————————————————————————————————————————————————————————————————————————————————————

2.函数join的作用:用指定的字符(串)连接列表的元素

  

a = "This is a test for some function"
b = a.split(' ')
print '#'.join(b)
print ' %'.join(b)
print ''.join(b)

————————————————————————————————————————————————————————————————————————————————————

3.list中 【】 内为基数,因此 (-1)指列表的最后一个元素

————————————————————————————————————————————————————————————————————————————————————

4.oop(object-oriented programming)

  面对对象编程,

  目的:解决编程项目庞大时变量名重叠,可读性可扩展性降低

  方法:运用 类(对象的抽象化)解决

  类——对对象的抽象化,类和对象就好比数学方程式和解决具体的数学问题。后者是前者的特异性个体,包涵在前者之内。

  特点:高内聚低耦合等等等等

 ————————————————————————————————————————————————————————————————————————————————————

5.关于class  http://www.cnblogs.com/longdouhzt/archive/2012/05/16/2505141.html

暂时放一下

————————————————————————————————————————————————————————————————————————————————————

6.函数式编程(functional programming)

  函数第一位

  变量的恒常性——相较oop的变量只是用作暂时的存储

  输出结果的恒常——不同环境下输出结果一致

参考:http://www.ruanyifeng.com/blog/2012/04/functional_programming.html

posted on 2016-08-14 11:35  公子不吃梨  阅读(202)  评论(0编辑  收藏  举报