python中input需要转换类型

上一篇 / 下一篇  2012-12-11 12:51:10 / 个人分类:python

在editplus V3.41版本中,敲入以下代码:
     #!/usr/bin/python
     # -*- coding: UTF-8 -*-
     # if elif else语句
      score = input("score:")
      print(score)
      score = int(score)      //此处需要转换类型,否则出错
      if(score >= 90) and (score <= 100):
        print ("A")
      elif(score >= 80) and (score < 90):
        print ("B")
      elif(score >= 60) and (score < 80):
        print ("C")
      else:
        print ("D")

TAG: input

 

评分:0

我来说两句

Open Toolbar