- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What does the 'b' character do in front of a string literal in Python?
A prefix of 'b' or 'B' is ignored in Python 2.
In Python 3, Bytes literals are always prefixed with 'b' or 'B'; they produce an instance of the bytes type instead of the str type. They may only contain ASCII characters; bytes with a numeric value of 128 or greater must be expressed with escapes.
Python 3.x makes a clear distinction between the types:
str = '...' literals = a sequence of Unicode characters (UTF-16 or UTF-32, depending on how Python was compiled)
bytes = b'...' literals = a sequence of octets (integers between 0 and 255)
- What is @ in front of a string in C#?
- What is a string literal in C++?
- What does the 'b' modifier do when a file is opened using Python?
- What is Java String literal?
- What does the &= operator do in Python?
- What is the difference between a String object and a String literal in Java?
- What does the @ prefix do on string literals in C#?
- What does the operation c=a+++b mean in C/C++?
- What does the >> operator do in Python?
- What does % do to strings in Python?
- What does reload() function do in Python?
- What does method time.tzset() do in Python?
- What does raw_input() function do in python?
- What does input() function do in python?
- What does print() function do in Python?