The string entered with input () is a 8385 message such as: \x30\x30\x30\x30 ... , but after the input, the code adds a \, like \\x30, to the 8583 message string.
But I commented out the input () code, wrote 8583 messages in the variable to die, there is no problem, I think it should be caused by coding problems.
Input inputs and variables are fixed, is there anything different?
The code is as follows:
The input of the SLR slash, is automatically escaped by the system double backslash \\x, the code adds the basis to judge:
1 if " \\x " in INPUT_A1:
Adding decode ("Unicode_escape") solves the problem when input () keyboard is entered.
The code is as follows:
1 #Coding:utf-82 3 #fixed 8583 message 16 binary data4A ="\x31\x31\x39\x39\x30\x36\x30\x30\x30\x32\x30\x30"5 Print(Type (a))6 Print(a)7b =Str (a)8 Print("variable-->%s"%b)9 Ten One #8583 message 16 binary data copied via the keyboard A #\x31\x31\x39\x39\x30\x36\x30\x30\x30\x32\x30\x30 -Input_a = Raw_input ("input 1->:"). Decode ("Unicode_escape") - if "\\x" inchinput_a: the Print("the input of the SLR slash, is automatically escaped by the system double backslash \\x") - Else : - Print("using the Unicode_escape Storage Memory value method, the 8583 message of the input SLR slash is not escaped") - Print(Type (input_a)) +b =Str (input_a) - Print("keyboard-->%s"%b) + A #Check the problem atINPUT_A1 = Raw_input ("input 2->:") - if "\\x" inchINPUT_A1: - Print("the input of the SLR slash, is automatically escaped by the system double backslash \\x") - Else : - Print(Type (input_a)) -b =Str (input_a) in Print("keyboard-->%s"%b
Baidu has some information, our data string is usually the str, Unicode type, basically is directly stored in the way, there is a way to store the memory encoded by the string, it is to read the string and then reverse back.
1>>> u'Chinese test'. Encode ('Unicode-escape')2 '\\u4e2d\\u6587\\u6d4b\\u8bd5'3 4>>>'\\u4e2d\\u6587\\u6d4b\\u8bd5'. Decode ('Unicode-escape')5U'\u4e2d\u6587\u6d4b\u8bd5'
Python input () keyboard input 8583 messages with \x SLR Slash auto-escaping problem solving method