Determine the type of an object?

后端 未结 13 2347
余生分开走
余生分开走 2020-11-22 05:50

Is there a simple way to determine if a variable is a list, dictionary, or something else? I am getting an object back that may be either type and I need to be able to tell

13条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 06:16

    You can do that using type():

    >>> a = []
    >>> type(a)
    
    >>> f = ()
    >>> type(f)
    
    

提交回复
热议问题