优先用isinstance,而不是type
isinstance
type
>>> isinstance(2, float) False >>> isinstance('a', (str, unicode)) True >>> isinstance((2, 3), (str, list, tuple)) True