How to compare type of an object in Python?

后端 未结 14 2445
闹比i
闹比i 2020-11-28 01:26

Basically I want to do this:

obj = \'str\'
type ( obj ) == string

I tried:

type ( obj ) == type ( string )
<
14条回答
  •  执笔经年
    2020-11-28 02:00

    Use str instead of string

    type ( obj ) == str
    

    Explanation

    >>> a = "Hello"
    >>> type(a)==str
    True
    >>> type(a)
    
    >>>
    

提交回复
热议问题