Reputation: 5575
How do i detect <class 'bytes'>
objects in Python?
I want something along the lines of
if type(x) == bytes:
doesomething(x)
Upvotes: 0
Views: 1292
Reputation: 78554
You can simply do:
if type(x) is bytes
Or:
if isinstance(s, bytes)
Upvotes: 2