摘要: __new__() 类的静态方法,用于确定是否要创建对象__init__() 构造函数,生成对象时调用__del__() 析构函数,释放对象时调用__add__() +__sub__() -__mul__() *__truediv__() /__floordiv__() //__mod__() %_ 阅读全文
posted @ 2017-05-31 17:08 JustLittle 阅读(351) 评论(0) 推荐(0)
摘要: 11self.__value: 3Root.__total: 122self.__value: 3Root.__total: 2self.__value: 3Root.__total: 2self.__value: 5Root.__total: 2self.__value: 5Root.__tota 阅读全文
posted @ 2017-05-31 14:07 JustLittle 阅读(427) 评论(0) 推荐(0)
摘要: 方法用来描述对象所具有的行为,例如,列表对象的追加元素、插入元素、删除原宿、排序,字符串对象的分隔、连接、排版、替换、烤箱的温度设置、烘烤,等等 在类中定义的方法可以粗略分为四大类:公有方法、私有方法、静态方法和类方法。公有方法、私有方法一般是指属于对象的实例方法,其中私有方法的的名字以两个下划线( 阅读全文
posted @ 2017-05-31 11:51 JustLittle 阅读(1905) 评论(0) 推荐(0)
摘要: >>> def main(n): start = 10**(n-1)+2 end = start*10-20 for i in range(start,end): i = str(i) big = ''.join(sorted(i,reverse=True)) big = int(big) litt 阅读全文
posted @ 2017-05-31 09:01 JustLittle 阅读(1562) 评论(0) 推荐(0)
摘要: '''据说古代有一个梵塔,塔内有三个底座A、B、C,A座上有64个盘子,盘子大小不等,大的在下,小的在上。有一个和尚想把这64个盘子从A座移到C座,但每次只能允许移动一个盘子,在移动盘子的过程中可以利用B座,但任何时刻3个座上的盘子都必须始终保持大盘在下、小盘在上的顺序。如果只有一个盘子,则不需要利 阅读全文
posted @ 2017-05-31 08:50 JustLittle 阅读(1495) 评论(0) 推荐(0)
摘要: >>> def printMax(a,b): if a>b: print(a,'is the max') else: print(b,'is hte max') >>> def addOne(a): print(a) a+=1 print(a) >>> a=3>>> addOne(a)34>>> d 阅读全文
posted @ 2017-05-25 15:22 JustLittle 阅读(328) 评论(0) 推荐(0)
摘要: 1 >>> def check_permission(func): 2 def wrapper(*args,**kwargs): 3 if kwargs.get('username')!='admin': 4 raise Exception('Sorry.You are not allowed.') 5 return func(*args,**kwargs) 6 return wra... 阅读全文
posted @ 2017-05-25 09:29 JustLittle 阅读(317) 评论(0) 推荐(0)
摘要: >>> from datetime import date>>> daysOfMonth=[31,28,31,30,31,30,31,31,30,31,30,31] >>> def myCalendar(year,month): start=date(year,month,1).timetuple( 阅读全文
posted @ 2017-05-24 14:18 JustLittle 阅读(359) 评论(0) 推荐(0)
摘要: >>> import datetime>>> Today=datetime.date.today()>>> Todaydatetime.date(2017, 5, 24)>>> Today-datetime.date(Today.year,1,1)+datetime.timedelta(days=1 阅读全文
posted @ 2017-05-24 13:45 JustLittle 阅读(157) 评论(0) 推荐(0)
摘要: >>> if 3>2:print('ok') ok>>> if True:print(3);print(5) 35>>> chTesst=['1','2','3','4','5']>>> if chTesst: print(chTesst)else: print('Empty') ['1', '2' 阅读全文
posted @ 2017-05-23 21:11 JustLittle 阅读(4524) 评论(0) 推荐(0)