This post will show you how to remove https from a url in python. You can use the same method to remove any substring from a string. For example, if our url is https://www.google.com, it will convert it to www.google.com.
I will show you two different methods to solve this problem.
replace() method is used to replace a substring in a string with a different substring. We can use this method to remove https from a url as like below :
given_url = 'https://www.google.com' print(given_url.replace('https://',''))
It will print www.google.com.
Here, we are using replace method to replace https:// with a blank character.
regex or Regular Expression is another way to replace a substring. Regex is used for complex tasks than this, but you can use it to remove https:// from a url as like below :
import re given_url = 'https://www.google.com' print(re.sub('https://','',given_url))
It will print the same output.