Forums

Bug with #

Hi, I'm making a public API system with json URL. In this public API system I have to display some files from PC to site like files opened (This isn't a virus my project is on Github) etc... If I've got an URL contains # this URL bugs all json's results. Example: mrcreeper2010.pythonanywhere.com/hi#jkl string after # doesn't display and it will break all results after #.

A # has meaning in a URL - it indicates the page fragment: https://en.wikipedia.org/wiki/URI_fragment. If you want to have #s in your URLs, you will need to escape them.

Can I automatically escape this char?

You will have to encode it yourself. Probably using something like urllib.parse.quote