Use r-string to avoid raising Python 3 SyntaxError
In Python 2 the string and the r-string behave the same: $ __python2__ ``` >>> '$\Uparrow$ ' '$\\Uparrow$ ' >>> r'$\Uparrow$ ' '$\\Uparrow$ ' >>> '$\Uparrow$ ' == r'$\Uparrow$ ' True ``` In Python 3 the string raises a Syntax Error while the r-string works just like Python 2. ``` >>> '$\Uparrow$ ' File "<stdin>", line 1 SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 1-2: truncated \UXXXXXXXX escape >>> r'$\Uparrow$ ' '$\\Uparrow$ ' ```
Showing
Please register or sign in to comment