What does “\00” mean in Python? To learn more about this, I tried following:
- When I assign
d="\00"and callprint d, nothing displays on the screen. - I also tried assigning
dto a string with extra spacing between and at the end and then calledd.replace("\00", ""), but no result was evident.
What does d.replace("\00","") do? Will it merely look for this particular string “\00” and replace it with an empty string?
In Python 2, when a number starts with a leading zero, it means it’s in octal (base 8). In Python 3 octal literals start with
0oinstead.00specifically is 0.The leading
\in\00is a way of specifying a byte value, a number between 0-255. It’s normally used to represent a character that isn’t on your keyboard, or otherwise can’t be easily represented in a string. Some special characters also have non-numeric “escape codes”, like\nfor a newline.The zero byte is also known as the nul byte or null byte. It doesn’t display anything when printed — it’s null.
See http://www.ascii.cl/ for ASCII character codes.
Yes,
replacewill still work with it, it just has no meaning as a display character.It’s sometimes used for other purposes, see http://en.wikipedia.org/wiki/Null_character.