Clover
0
Q:

python check type

v = 10
type(v)
# <type 'int'>
16
>>>foo = "Hello, World!"
>>>isinstance(foo, str) # isinstance(<input>, <type>)
True
>>>isinstance(foo, int)
False
8
str = "Hello"
type(str)
4
## To get the type of a variable, use 'type()'
type("Hello World!")
## Output:
## str
2
isinstance(object, classinfo) 
The isinstance() takes two parameters:
object : object to be checked
classinfo : class, type, or tuple of classes and types
1

New to Communities?

Join the community