Jacob Dalton
Jacob Dalton

Reputation: 1703

How do I convert a numpy uint8 to the default int type in Python?

How to I convert a uint8 created by numpy to a standard Python int so that it can be serialized to json?

Upvotes: 3

Views: 7081

Answers (1)

Silvio Mayolo
Silvio Mayolo

Reputation: 70317

Consider int.

a = numpy.uint8(some_number)
b = int(a)
print(type(b)) # <class 'int'>

Upvotes: 5

Related Questions