Different interpretation of hex strings in python
问题 In the past few days, I've been struggling to understand why this piece of codes behaves in such a way: code: file1 = open("input.txt","r") M = file1.read() file1.close() print(M) print(M.encode("latin")) print(type(M.encode("latin"))) print("\n-----------------------------\n") t = "\xAC\x42\x4C\x45\x54\x43\x48\x49\x4E\x47\x4C\x45\x59" print(t) print(t.encode("latin")) print(type(t.encode("latin"))) file "input.txt" content: \xAC\x42\x4C\x45\x54\x43\x48\x49\x4E\x47\x4C\x45\x59 output: \xAC