Difference in python between basestring and types.StringType?

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

What\'s the difference between:

isinstance(foo, types.StringType)

and

isinstance(foo, basestring)

?

4条回答
  •  一生所求
    2021-02-07 20:10

    This stuff is completely different in Python3

    types not longer has StringType
    str is always unicode
    basestring no longer exists

    So try not to sprinkle that stuff through your code too much if you might ever need to port it

提交回复
热议问题