现在的位置: 首页 > 综合 > 正文

Python-if-elif-else语句

2013年09月08日 ⁄ 综合 ⁄ 共 1513字 ⁄ 字号 评论关闭

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

 

 

抱歉!评论已关闭.