首页 > 代码库 > Python9-1

Python9-1

for index, item in enumerate(sequence):    process(index, item)

列表初始化:

multilist = [[0 for col in range(5)] for row in range(3)]

用*初始化,出现的问题:

http://www.jb51.net/article/15716.htm

 

python内置函数:

int([x[, base]])      #将一个字符转换为int类型,base表示进制int(123) int(123,10)
chr(i)     返回整数i对应的ASCII字符与之相对应的是ord

一种很棒的先序便利树的方法:

def walk(node):    """ iterate tree in pre-order depth-first search order """    yield node    for child in node.children:        for n in walk(child):            yield n

python高级数据结构

http://blog.jobbole.com/65218/

python中__attr,以__开头的属性是private的。外界访问不到。

class A(object):      def __init__(self):          self.__age=10  a=A()  print a.__age Traceback (most recent call last):    File "H:\final\code\PyTestService\comz\test\Copy of Copy of Test.py", line 12, in <module>      print a.__age  AttributeError: A object has no attribute __age

python数据描述符

http://blog.csdn.net/imzoer/article/details/8788040

python性能建议

http://blog.csdn.net/imzoer/article/details/8851678

 

Python9-1