每日学习笔记(1)

  1python2.4不支持下面这种异常处理语法

try :  
  
except :  
  
finally

只有2.5以上才行,为此只能改成下述写法,damn fuck python 2.4...

try :  
    
try :  
    
    
except :  
  
finally :

2,python实现单例模式的一种方法:

代码
class  MyClass:
    _instance 
=  None
    
    
def   __init__ (self):
        
pass
        
    @staticmethod
    
def  getInstance():
        
if   not  MyClass._instance:
            MyClass._instance 
=  MyClass()
        
return  MyClass._instance

 3,python读取文本文件

代码
        f  =  open(filePath)  # 打开文本文件,默认模式是只读
         try :   # damn python 2.4...
             try :
                
for  line  in  f:
                    name,age 
=  line.split()  # 每一行是name,age
                    process(name,age)  # 进行处理
             except  EOFError: 
                
pass
        
finally :
            f.close()

 4,python实现以POST方式提交数据

代码
    params  =  urllib.urlencode({ ' name ' :self.name})    
    
try :
        
try # damn python 2.4...
            conn  =  urllib2.urlopen(self.crossBattleServiceURL, params)  # 提交请求
            result  =  conn.read()
            
print  result
                    
        
except  HTTPError,e:
            
print   ' http error: ' ,e.reason
            
        
except  URLError,e:
            
print   ' url error: ' ,e.reason
    
finally :
        conn.close()

 5,Android中调试服务

      参考文章:http://www.helloandroid.com/tutorials/how-debug-service

      Androidservice的调试和普通的Application不同,如果仅仅设置断点的话,调试器是不会在你的断点处停下来的,解决方法就是

      在代码中声明,以便让调试器能到你声明的地方。你只需加入下面这一句代码即可:

    android.os.Debug.waitForDebugger();

      你的断点可以设置在这句调用后面任何地方。

      举例如下:

代码
     public   class  SoftKeyboard  extends  InputMethodService  implements  KeyboardView.OnKeyboardActionListener 
    {
       
        @Override
        
public   void  onConfigurationChanged(Configuration newConfig) 
        {
            Log.d(
" SoftKeyboard " " onConfigurationChanged() " );
 
            
/*  now let's wait until the debugger attaches  */
            android.os.Debug.waitForDebugger();
       
            
super .onConfigurationChanged(newConfig);
       
            
/*  do something useful...  */
               
        }

 

6HTML5的前景确实是越来越明朗化了,不断有新的游戏作品出来,但flash短时间内肯定还是可以维持目前的王者之位,不过Adobe真的要努力了。看看Google这个Quake II的移植项目,感兴趣的话可以一试:

http://www.cnbeta.com/articles/107768.htm

http://code.google.com/p/quake2-gwt-port/

 

### 英语学习笔记的重要性 每日英语学习笔记是一种有效的方法来巩固所学的知识并提高语言能力。通过记录每天的学习内容,不仅可以帮助记忆新单词和语法结构,还能跟踪自己的进步情况[^1]。 #### 如何创建有效的英语学习笔记1. **设定目标**: 明确每天想要达成的目标,比如掌握一定数量的新词或者完成一段特定长度的文章翻译。 2. **分类整理**: 将笔记分为不同的部分,例如词汇表、句型练习以及文化背景知识等。这样便于日后查阅复习[^2]。 3. **实践应用**: 记录下实际使用的例子,像“You've been working around the clock!”这样的句子不仅展示了如何运用短语“around the clock”,还体现了其在日常交流中的作用。 4. **技术辅助**: 利用现代工具和技术手段提升效率。例如,在视频编辑软件中利用标记功能可以帮助记住关键时刻的内容;同样地,也可以采用类似的数字化方式管理个人的语言资料库. 5. **反思总结**: 定期回顾之前的笔记,并尝试用自己的话重新表述其中的概念,以此检验理解程度是否深刻到位[^3]. 6. **跨文化交流意识培养**: 学习过程中注意了解不同国家的文化差异及其对企业全球化战略的影响等因素,这有助于形成更全面的世界观视角[^4]. ```python class EnglishNote: def __init__(self, date, new_words=[], example_sentences=[]): self.date = date self.new_words = new_words self.example_sentences = example_sentences def add_word(self, word): self.new_words.append(word) def add_sentence(self, sentence): self.example_sentences.append(sentence) note = EnglishNote("2023-10-07") note.add_word("around the clock") note.add_sentence("You've been working around the clock!") print(note.__dict__) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值