Remove Trailing Slash from URL in Python
To remove the trailing slash from a URL in Python, you can use the rstrip() method as follows:
url = 'https://aeon-ai-chat.netlify.app/'
url = url.rstrip('/')
print(url)
This will output:
https://aeon-ai-chat.netlify.app
The rstrip() method removes all trailing occurrences of the specified character (in this case the slash '/') from the end of the string.
原文地址: https://www.cveoy.top/t/topic/nXry 著作权归作者所有。请勿转载和采集!