首页 > 代码库 > Python笔记

Python笔记

#coding:utf-8
a = raw_input()
try:
    if int(a) > 0:
      print ‘输入为正数‘
    elif int(a) < 0:
        print ‘输入为负数‘
    else:
        print ‘输入为0‘
except Exception,e:
    print ‘请输入数字‘

  抓取异常,Python缩进格式要求严格,与Java不同

Python笔记