I'm trying to parse URLs and count the number of Backslashes. However, in Python, this sign does not parse URLs with hex values. When I use another symbol, such as a slash ('/'), the code works well even with hex numbers. Also, when I alter the hex values to a random string, the code correctly counts the Backslashes. Here's my code:
url = "https://www.example.com/na.g?taetID\x3d5358\1542099"
print(backslashes(url))
#the output>> 0
#-------
#if I change the hex values to a random string:
#url = "https://www.example.com/na.g?taetID\mnbc\zxcd"
#print(backslashes(url))>> 2
I want to count the number of Backslashes in all URLs, even those with hex values. In the URL above, there are two backslashes.
backslashesfunction from your question? now your code makes no sense. Anyway, from my understanding what you are seeing is not an error, it is by design. try printing just \x, you will get a syntax error. why do you need to count the backslashes on your URL? What is the purpose. there may be better ways to do it.