\s is a character class that represents either a space , tab space or newline. This is used in the regular expression to extract one character that belongs to any one of the aforementioned classes. They can be clubbed together to find groups just like any other regular expression pattern.
Let us take an example.
Regex_Object = re.compile(r'\s')
mo1 = Regex_Object.sub('','a b c \n d')
print('THE NEW STRING IS '+mo1)
THE NEW STRING IS abcd
In the example there should be a match on anything that is a space , tab space or new line . The spaces, tab and newline in the string are replaced by an empty string using the .sub() method.