Python-if-elif-else語句


Source:

 

Result:

 

[work@db-testing-com06-vm3.db01.baidu.com python]$ python if_else.py 

#### if-else ####

a: 12 + 8

b: 30

max:  30

#### if-elif-else ####

score: 88

B

#### switch ####

0.5

#### switch II ####

3

 

================================================================

中文注釋參考:

 

一個極小的問題。在python代碼中,用了中文注釋,不能被python解釋器理解(python 2.5)。解決方案是:

# coding=gb2312
print 'ok' #中文注釋沒問題

或者:

# -*- coding: gb2312 -*-
print 'ok'  #這樣也行

 

 

代碼詳解參考:

http://blog.csdn.net/Lynn_yan/archive/2010/04/08/5464911.aspx

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM