@
pythonbeginner 一般的话……
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'florije'
if __name__ == '__main__':
running = True
while running:
var = raw_input('pls enter something: ')
# todo deeply setting something
try:
result = int(var)
running = False
result += 1
print result
except Exception:
try:
result = float(var)
running = False
result -= 1
print result
except Exception:
print "neither int or float"
if isinstance(var, str):
print "You entered a string, pls try again."
else:
print "Are you joking?"