python print type code example
Example 1: print variable type python
v = 10
type(v)
Example 2: how to check the type of a variable in python
print(type(x))
Example 3: python except print error type
>>> try:
... raise Exception('spam', 'eggs')
... except Exception as inst:
... print(type(inst))
... print(inst.args)
... print(inst)
...
... x, y = inst.args
... print('x =', x)
... print('y =', y)
...
<class 'Exception'>
('spam', 'eggs')
('spam', 'eggs')
x = spam
y = eggs
Example 4: check type of variable in python
str = "Hello"
type(str)