5
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?

ruohola
  • 21,987
  • 6
  • 62
  • 97
user1424739
  • 11,937
  • 17
  • 63
  • 152

1 Answers1

6

Yes that is, you can either use a raw string r'\s+' or alternatively escape the backslash with '\\s+'.

ruohola
  • 21,987
  • 6
  • 62
  • 97