Example 1: Using strip()
my_string = " Python "
print(my_string.strip())
Example 2: Using regular expression
import re
my_string = " Hello Python "
output = re.sub(r'^\s+|\s+$', '', my_string)
print(output)
Using decode() print(b'Easy \xE2\x9C\x85'.decode("utf-8"))
0 Comments