re.compile('\s+', flags = re.UNICODE)
The above code gives the following warning in python3.
SyntaxWarning: invalid escape sequence \s
I fix it by using r'\s+'
. Is it a correct way to fix the problem?
re.compile('\s+', flags = re.UNICODE)
The above code gives the following warning in python3.
SyntaxWarning: invalid escape sequence \s
I fix it by using r'\s+'
. Is it a correct way to fix the problem?
Yes that is, you can either use a raw string r'\s+'
or alternatively escape the backslash with '\\s+'
.