在python中可以通过try...except语句来简单的判断字符串是否为整数,具体如例程

x = raw_input('>')

try:

   return int(x)

except ValueError:

   return None