Answers for "python print type"

22

how to check the type of a variable in python

print(type(x))
Posted by: Guest on May-28-2020
1

python except print error type

>>> try:
...     raise Exception('spam', 'eggs')
... except Exception as inst:
...     print(type(inst))    # the exception instance
...     print(inst.args)     # arguments stored in .args
...     print(inst)          # __str__ allows args to be printed directly,
...                          # but may be overridden in exception subclasses
...     x, y = inst.args     # unpack args
...     print('x =', x)
...     print('y =', y)
...
<class 'Exception'>
('spam', 'eggs')
('spam', 'eggs')
x = spam
y = eggs
Posted by: Guest on December-10-2020
-1

how to print data type in python

var = 23.0
print(type(var)
Posted by: Guest on February-20-2021

Python Answers by Framework

Browse Popular Code Answers by Language