sunsir 发表于 2018-8-8 13:54:32

python代码优化案例分析

def displayNumType(num):  
    print num,"is",
  
    if type(num)==type(0):
  
      print 'an interger'
  
    elif type(num)==type(0L):
  
      print 'a long'
  
    elif type(num)==type(0.0):
  
      print 'a float'
  
    elif type(num)==type(0+0j):
  
      print 'a complex number'
  
    else:
  
      print 'not a number at all!!'
页: [1]
查看完整版本: python代码优化案例分析