摘要: 面向对象类中的属性: 域和方法类的方法的第一个参数为self(类似于this指针),调用时无需写明__init__方法,在类的对象被建立时,马上运行。(类似于构造函数)def __init__(slef, name):__del__方法,(类似于析构函数)有两种类型的 域:类的变量和对象的变量(类似于c#中静态变量),是否有self来区分两者。python中所有类成员是公共的,方法是有效地。例外:双下划线为前缀的数据成员是私有的。继承: 1 # Filename: inherit.py 2 class SchoolMember: 3 "'Represents any scho 阅读全文
posted @ 2012-03-17 22:05 Alex_Monkey 阅读(295) 评论(0) 推荐(0) 编辑
摘要: 一个归档的小程序。 1 # Filename: backup_ver3 2 import os 3 import time 4 #import sys 5 #reload(sys) 6 #sys.setdefaultencoding('utf8') 7 # 1. The files and directories to be backed up are specified in a list. 8 source = ['C:\\networkx.txt', 'c:\\backup\\'] 9 10 # 2. The backip must be 阅读全文
posted @ 2012-03-17 18:57 Alex_Monkey 阅读(321) 评论(0) 推荐(0) 编辑
摘要: python中有三种内部数据结构:列表、元组、字典(using_list.py,using_tuple.py, using——dict.py)list:列表。shoplist = ['apple', 'mango', 'carrot', 'banana'] 方法,尾部添加shoplist.append('rice'),排序shoplist.sort(),删除del shoplist[i] 1 # Filename: using_list.py 2 # This is my shopping list 3 shopl 阅读全文
posted @ 2012-03-17 14:05 Alex_Monkey 阅读(1593) 评论(0) 推荐(0) 编辑
摘要: python中有四种类型的数:整形 长整型 浮点数 复数python用缩进来标示语句块字符串下一行继续用 \"This is the first sentence.\This is the second sentence."自然字符串即非转义字符串,加前缀r或Rr"hello, world"unicode编码加前缀u或Uu"This is a unicode string"级联字符串'What\'s' 'your name?' = "What's your name?" 阅读全文
posted @ 2012-03-17 00:54 Alex_Monkey 阅读(381) 评论(0) 推荐(0) 编辑