+ 15
Please tell why we are getting this output??
34 Réponses
+ 7
If you write a = '25\\24', you get the result you probably expect.
I have no idea what exactly is happening if you don't though.
Is the second half of the string read as some sort of strange escape sequence? 🤔
+ 5
RAJESH SAHU
Try this a="25\\24"
+ 5
george yeah you are correct
+ 5
Hint:
When a question ends up in hot today and has more than 30 answers, probably your answer has already been given. 😉
https://code.sololearn.com/cMBvMY2UD8MB/?ref=app
+ 4
\x14 is the byte representation of 20 in decimal or 24 in octal. \24 to the str.split() is octal representation as str.split() does not use the STDOUT buffer. Instead it tries to give you a character. Since the character with value 14 hex is not in the character space. It encodes the raw byte value to the string.
P. S. \nn or \nnn where n is any digit is octal representation on number in Python.
+ 3
A backslash is an escape sequence in ASCII. UTF-8 is backwards compatible to ASCII and the output buffer of STDOUT of Python reads any sequence after backslash as an escape sequence. By using '\24' you are giving the STDOUT buffer to use escape sequence 24 (which you should find documented with ASCII Standards).
As mentioned by HonFu using '\\' will resolve the error as that is the escape sequence of backslash character.
+ 3
Octal 24 = Binary 10100
Binary 00010100 = 14 Hex
+ 2
𝐏𝖗𝖎𝖓𝖈𝖊🤘[𝐈𝖓𝖆𝖈𝖙𝖎𝖛𝖊], he's asking about that very specific strange output he gets in the code.
Most generic explanations don't seem to touch this.
+ 2
\24 means octal value in python
+ 2
RAJESH SAHU \x14 is the byte representation of 20 in decimal or 24 in octal. \24 to the str.split() is octal representation as str.split() does not use the STDOUT buffer. Instead it tries to give you a character when your specified attribute is not found in the given string.
Since the character with value 14 hex is not in the character space. It encodes the raw byte value to the string.
So to get the result you are expecting i recomend you reqrite your code like this:
a="25\24"
print(a)
b=a.split("\")
print(b)
There when you remove the other backslash in the string method. It will take that backslash as reference if i can say and rerturns values that are dividded by the backslash. Thus your output will be:
b = ['25', '24']
+ 1
RAJESH SAHU problem in 25\24. you need to write 25\\24 to get real 25 and 24 symbols. in your case \24 system recognize \2 as some spec symbol and 5 other sumbol
+ 1
if you want to use symbol \ as literal you need to \\ , since \ is spec symbol. this is same manner if tou nedd youse “ or ‘ symbols as literals “ lalala\””
+ 1
Thanks Everyone🙂
+ 1
P𝖗𝖎𝖓𝖈𝖊🤘[l𝖓𝖆𝖈𝖙𝖎𝖛𝖊] Sahi jagah post kiya tha. Wo block ho gayi.
+ 1
AJ Anant Ooh. aisa kya kiya tha usne??
+ 1
'a' needs a second backslash too :)
+ 1
RAJESH SAHU
The Reason is Tgat In Python When You Want To add a Back_Slash to a string you can't add it juat like that "\" it's because the back slash is used to add symbol and many things some of them you may not find in your keyboard i think
The best ex. i can offer is..
When You Need to add a double quote and a single quote to the same string you'll have to use the back slash
for example
print('There\'s a new car in the street it\'s the first time i see it here')
the single quote in the beginning and the end are used declare the string and the quotes between them that follow the backslash are part of the string
i hope i helped and sorry if i messed up somewhere my English isn't that strong😅😛
0
Found 👇👇
https://stackoverflow.com/questions/37484624/split-string-at-delimiter-in-JUMP_LINK__&&__python__&&__JUMP_LINK
Not sure exactly it will solve your problem.
0
Thanks for your explanation everyone..but I have a doubt when I wrote
a="25\24"
b=a.split("\\")
print(b)
I thought "b" will be ["25","24"]
But output came as ["25\x14"]..
please tell what is the reason for the output...
0
Anubhav Mattoo
can you please tell how to convert oct \24 to \x14
I am not getting how it is?