How to check if a variable's type is primitive?

前端 未结 7 1144
难免孤独
难免孤独 2020-12-05 12:57

I don\'t know how to check if a variable is primitive. In Java it\'s like this:

if var.isPrimitive():
7条回答
  •  有刺的猬
    2020-12-05 13:38

    You may want to take a look at types module, that lists all python built-in types.

    http://docs.python.org/library/types.html

提交回复
热议问题