Skip to main content

Bytes literals in Python

In Byte Literal we used to produce a new object each time it is evaluated which is like and unlike string beacuse bytes literal, like lists and unlike strings are mutable.

Bytes Literal is similar to string literal with the addition of a 'b' prefix.

It is a single ASCII character (in the U+0000 to U+007F range) or a single escape preceded by the characters U+0062 ( b ) and U+0027 (single-quote), and followed by the character U+0027.


x= b'abc'

Output: 'abc'

Submitted by devanshi.srivastava on September 5, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.