Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vs code different color for backslash in r string

in visual studio code, the line below \U and \P and \L are shown in a different color even though they have no effect in r strings why is that?

app = r'C:\Users\Sandramohan\AppData\Local\Programs\Python\Python38\python.exe'

vs code image

like image 205
Thenujan Sandramohan Avatar asked Apr 18 '26 16:04

Thenujan Sandramohan


1 Answers

It's a feature - apparently a lower 'r' is colored as regex, whereas a capital 'R' is colored as a rawstring.

Use a capital R to get correct coloring:

app = R"C:\Hello\World"
like image 116
Bip901 Avatar answered Apr 20 '26 06:04

Bip901



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!