python中使用types函數判斷數據類型,具體方法如下:
1.判斷是否是int類型
import types #導入types模塊type(x) is types.IntType
import types #導入types模塊
type(x) is types.IntType
2.判斷是否是string類型
import types #導入types模塊type(x) is types.StringType
type(x) is types.StringType
3.判斷是否是number類型
import types #導入types模塊type(x) is types.NumberType
type(x) is types.NumberType