Difference in python between basestring and types.StringType?

后端 未结 4 1366
一向
一向 2021-02-07 19:25

What\'s the difference between:

isinstance(foo, types.StringType)

and

isinstance(foo, basestring)

?

4条回答
  •  逝去的感伤
    2021-02-07 19:48

    >>> import types
    >>> isinstance(u'ciao', types.StringType)
    False
    >>> isinstance(u'ciao', basestring)
    True
    >>> 
    

    Pretty important difference, it seems to me;-).

提交回复
热议问题