python日常

1029 ワード

私の不確実な基本功を記録する
  • str()は何ですか?クラスに__str__が定義されている場合、printのクラスのインスタンスが実行されると、__str__のコード
  • が実行される.
  • 異常なスナップtry...except...else.....finally
  • 1.   except    else      return,finally         
    2.                     ,         __str__   ,     str     ,       except someException as e ,print e   
    
  • いくつかのコード仕様:
  • 1. import    ,    ,     ,          
                 
    2.        # -*- coding:utf-8 -*-
    3.          ,        
    4.         ,        ,       
    5.    ,        ,        ,          
    6.        ,    # -*-。。。   import  
    
    
  • unittestを用いたユニットテスト
  •   ,import unittest 
    
    5. schedule           
    
    6. property    setter  :
    ![image.png](http://upload-images.jianshu.io/upload_images/9693291-f38181dc954d9500.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
    
    
    7.     ,      ,        
        1.   
        2.   
        3.   
        4.   :               ,                  ,       
    
        :
        1.       
        2.