获取对象的信息之内置函数type()
class MyClass(object):
pass
mc = MyClass()
print(type(mc))#<class '__main__.MyClass'>
print(type(18))
print(type("abc"))
print(type(MyClass))
print(type(int))
print(type(str))
def do_sth():
pass
print(type(do_sth))#<class 'function'>
print(type(print))#<class 'builtin_function_or_method'>
print(type(18)==int)
print(type('abc')==str)
# print(type(do_sth)==function)
# print(type(print)==builtin_function_or_method)
import types
print(type(do_sth)==types.FunctionType)
print(type(print)==types.BuiltinFunctionType)