The operators we have seen so far are all special characters like + and *, but there are a few operators that are words. in is a boolean operator that...
                            
                            
                                分类:
其他好文   时间:
2014-07-07 15:39:31   
                                阅读次数:
246
                             
                    
                        
                            
                            
                                元组通过圆括号中用逗号分割的项目定义。元组通常用在使语句或用户定义的函数能够安全地采用一组值的时候,即被使用的元组的值不会改变。含有0个或1个项目的元组。一个空的元组由一对空的圆括号组成,如myempty = ()。然而,含有单个元素的元组就不那么简单了。你必须在第一个(唯一一个)项目后跟一个逗号,...
                            
                            
                                分类:
编程语言   时间:
2014-07-07 08:30:25   
                                阅读次数:
211
                             
                    
                        
                            
                            
                                直接上代码吧#-*-coding:utf-8import osif os.path.exists('d:\\cpickle.data'): os.remove('d:\\cpickle.data')import cPickle as Pshoplist=['apple','banana','...
                            
                            
                                分类:
编程语言   时间:
2014-07-07 00:09:58   
                                阅读次数:
475
                             
                    
                        
                            
                            
                                #-*-coding:utf-8class Person: __privateName=None; count=0;#既可以被实例对象引用,也可以被当做静态对象引用,NND,好混乱。 def __init__(self,name): self.count+=1 ...
                            
                            
                                分类:
编程语言   时间:
2014-07-06 23:36:44   
                                阅读次数:
354
                             
                    
                        
                            
                            
                                继续在上一节的类的基础上测试继承:#-*-coding:utf-8import Syntax2class Student(Syntax2.Person): def __init__(self,name,age): Syntax2.Person.__init__(self,nam...
                            
                            
                                分类:
编程语言   时间:
2014-07-06 23:19:57   
                                阅读次数:
310
                             
                    
                        
                            
                            
                                __init__方法一样,还有一个特殊的方法__del__,它在对象消逝的时候被调用。但是很难保证这个方法究竟在什么时候运行。如果你想要指明它的运行,你就得使用del语句,#-*-coding:utf-8class Person: __privateName=None;#私有变量 cou...
                            
                            
                                分类:
编程语言   时间:
2014-07-05 20:28:10   
                                阅读次数:
270
                             
                    
                        
                            
                            
                                #-*-coding:utf-8import systry: strInput=int(raw_input('input sth.')) f=file('d:\\kjdsklslkdkl2l23223.datdk')except (EOFError,ValueError): #多重异常...
                            
                            
                                分类:
编程语言   时间:
2014-07-05 19:03:38   
                                阅读次数:
228
                             
                    
                        
                            
                            
                                列表综合 参见:http://woodpecker.org.cn/abyteofpython_cn/chinese/ch15s03.html#-*-coding:utf-8def ttt(value1,*args): for i in args: value1+=i pri...
                            
                            
                                分类:
编程语言   时间:
2014-07-05 18:53:17   
                                阅读次数:
206
                             
                    
                        
                            
                            
                                #!/usr/bin/python# Filename: for.pyfor i in range(1, 5): print ielse: print 'The for loop is over'for循环在这个范围内递归——for i in range(1,5)等价于for i in ...
                            
                            
                                分类:
编程语言   时间:
2014-07-02 19:12:24   
                                阅读次数:
288
                             
                    
                        
                            
                            
                                a=Nonefor i in a: print('zheli de i shi %d' % i)报错:TypeError: 'NoneType' object is not iterable除非你提供你自己的return语句,每个函数都在结尾暗含有return None语句。关于DocStri...
                            
                            
                                分类:
编程语言   时间:
2014-07-02 17:31:36   
                                阅读次数:
189