How do I check if raw input is integer in python 2.7?

前端 未结 5 1312
庸人自扰
庸人自扰 2020-11-28 15:28

Is there a method that I can use to check if a raw_input is an integer?

I found this method after researching in the web:

print isinsta         


        
5条回答
  •  猫巷女王i
    2020-11-28 16:19

    def checker():
      inputt = raw_input("how many u want to check?")
      try:
          return int(inputt)
      except ValueError:
          print "Error!, pls enter int!"
          return checker()
    

提交回复
热议问题