split用于分割字符串得到字串数组这是基本用法。如下: def str= "3 2" if(str.contains(" ")){ println str.split(' ')[0] // 3 } 可是换一种情况: def str= "3+2" if(str.contains("+")){ pri...
                            
                            
                                分类:
其他好文   时间:
2014-12-13 10:43:32   
                                阅读次数:
210
                             
                         
                    
                        
                            
                            
                                #!/usr/bin/pythonclass my_type(object): def __init__(self, v): self.value = v def __cmp__(self, v2): if self.value > v2.value: ...
                            
                            
                                分类:
编程语言   时间:
2014-12-12 23:28:00   
                                阅读次数:
191
                             
                         
                    
                        
                            
                            
                                0.57s,
import itertools
import time
def conquer():
    ans = 0
    DIGIT_LIMIT = 7
    ITER_STR = "0123456789"
    sum_square = lambda ss: sum( int( s ) ** 2 for s in str( ss ) )
    fact = lambda n...
                            
                            
                                分类:
其他好文   时间:
2014-12-12 22:15:46   
                                阅读次数:
247
                             
                         
                    
                        
                            
                            
                                原文地址:http://leihuang.org/2014/12/09/proxy/
Structural 模式 如何设计物件之间的静态结构,如何完成物件之间的继承、实 现与依赖关系,这关乎着系统设计出来是否健壮(robust):像是易懂、易维护、易修改、耦合度低等等议题。Structural 模式正如其名,其分类下的模式给出了在不同场合下所适用的各种物件关系结构。
Def...
                            
                            
                                分类:
其他好文   时间:
2014-12-12 22:14:03   
                                阅读次数:
184
                             
                         
                    
                        
                            
                            
                                利用play.api.mvc.Security的机制,实现一个trait,用于扩展controller的用户认证机制。
该trait需要实现的方法包括:
1. def username(request: RequestHeader) = request.session.get("email")
2. def onUnauthorized(request: RequestHeade...
                            
                            
                                分类:
其他好文   时间:
2014-12-12 20:57:31   
                                阅读次数:
152
                             
                         
                    
                        
                            
                            
                                1 # 12-1 FP树的类定义 2 class treeNode: 3 def _init_(self,nameValue,numOccur,parentNode): 4 self.name=nameValue; # 节点的名字 5 self.count=...
                            
                            
                                分类:
编程语言   时间:
2014-12-12 18:51:20   
                                阅读次数:
265
                             
                         
                    
                        
                            
                            
                                数据库和C#中均为可空类型。这时候直接给字段赋值为nullparameters[9].Value= null;执行的时候报错了,一大堆,总之说它少了一个参数。用sql server profiler 工具查看执行代码 如下图: 这时候才找到原因: C#中赋值为null的字段到了数据库执行变成了def...
                            
                            
                                分类:
数据库   时间:
2014-12-12 18:38:17   
                                阅读次数:
140
                             
                         
                    
                        
                            
                            
                                在窗口显示一张图片,代码如下: 1 import wx 2 3 class Frame(wx.Frame): 4 """Frame class that displays an image.""" 5 6 def __init__(self, image, parent=None...
                            
                            
                                分类:
编程语言   时间:
2014-12-12 06:41:24   
                                阅读次数:
282
                             
                         
                    
                        
                            
                            
                                Python in Action第二个例子,倒是很简单,却是最基本的GUI程序框架,里面有最基本的实现GUI流程1 import wx2 class MyApp(wx.App):3 def OnInit(self):4 frame=wx.Frame(parent=None,t...
                            
                            
                                分类:
编程语言   时间:
2014-12-12 01:19:45   
                                阅读次数:
197
                             
                         
                    
                        
                            
                            
                                #!/usr/bin/env python"""Spare.py is a starting point for simple wxPython programs."""import wxclass Frame(wx.Frame): passclass App(wx.App): def ...
                            
                            
                                分类:
编程语言   时间:
2014-12-12 01:19:24   
                                阅读次数:
212