1.任何非0,非None的值都认为True,0或是None为False
2.常用语句为if ... elif ... else ...
3.if语句可同时接多个条件,and必须都为True, or有一个为真就为True,否则为False
4.if语句还支持单行三元运算uname = uname if uname else 'limanman'
# -*- coding: utf-8 -*-
"""
#
# Authors: limanman
# OsChina: http://my.oschina.net/pydevops/
# Purpose:
#
"""
def main():
"""Main function. """
real_num = 521
guess_num = int(raw_input('please guess the real num: '))
if guess_num < real_num:
print 'Found Error: you need try bigger!'
elif guess_num > real_num:
print 'Found Error: you need try smaller!'
else:
print 'Found Succs: you got it!'
if __name__ == '__main__':
main()
print