简体   繁体   中英

Converting Hexadecimal character of string to normal characters in python

I have a scenario where I have to lodge file path to DB and while fetching the content, I am getting the special characters converted into Hexadecimal values. But with that path, I would not be able to open the files, so I need them in a normal string. I tried searching a lot but could not get the solution,
for example, I am getting the output as

"D:\nhubh\x07oo\x08\x07m"

and my expectation is:

D:\nhubh\aoo\b\am

Please help. Thanks in advance :)

Where was D:\\\\nhubh\\aoo\\b\\am used?

If it is in a string being fed to, say INSERT , then the backslashes need to be escaped:

D:\\\\nhubh\\aoo\\b\\am

If you are trying use that as a file path, then either of these works:

D:\\\\nhubh\\aoo\\b\\am
D://nhubh/aoo/b/am

Partial explanation:

The backspace 'character' is hex 08 or represented in some contexts as \\b . Similarly a=alert=07

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM