Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
binary = "\000\021\"\252\273\314". 这是我的输入,我的函数接受这个输入并像这样打印出来:
binary = "\000\021\"\252\273\314"
def do_print(string): print string do_print(binary)
但是这个函数会打印出乱码。我该如何解决这个问题?
也许你正在寻找repr字符串?
repr
def do_print(string): print(repr(string)) binary = "\000\021\"\252\273\314" do_print(binary)
产量
'\x00\x11"\xaa\xbb\xcc'