typeid

type函数返回一个对象的类型。举个例子:

  1. print(type(''))
  2. # Output: <type 'str'>
  3. print(type([]))
  4. # Output: <type 'list'>
  5. print(type({}))
  6. # Output: <type 'dict'>
  7. print(type(dict))
  8. # Output: <type 'type'>
  9. print(type(3))
  10. # Output: <type 'int'>

id()函数返回任意不同种类对象的唯一ID,举个例子:

  1. name ="Yasoob"
  2. print(id(name))
  3. # Output: 139972439030304