Python中的註釋寫法

1:單行註釋


Python中單行註釋爲在行首使用#字符

如:


#key,value=x.popitem()


2:多行註釋


Python中多行註釋採用''' 或者"""

如:

'''
import time  
import thread  
def timer(no, interval):  
    cnt = 0  
    while cnt<10:  
            print 'Thread:(%d) Time:%s\n'%(no, time.ctime())  
            time.sleep(interval)  
            cnt+=1  
    thread.exit_thread()  
  */       
       
def test(): #Use thread.start_new_thread() to create 2 new threads  
    thread.start_new_thread(timer, (1,1))  
    thread.start_new_thread(timer, (2,2))  
       
if __name__=='__main__':  
        test()  
'''



發佈了18 篇原創文章 · 獲贊 25 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章