简体   繁体   中英

Why type of 'int' is type?

I am printing type(int). Please explain me about this behaviour. thanks in advance.

print(type(int))

int itself is a type

type(0)
#int

type(int)
#type

Your example is no different to

print(type(type(0)))

int IS a type name (class name), while 1 is an object of type int

And "int" would be a string.

Check:

type(1) is int
type(int) is type
type("int") is str
type(str) is type
type(type) is type

Some build-in types are int , str , float , list , set , dict ... And yes, all those names by themselves are of type type

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM