Skip to content Skip to sidebar Skip to footer

What Causes Python Error 'bad Escape \c'?

I just wrote a function that will look at a text file and count all of the instances of True and False in the text file. Here is my file ATOM 43 CA LYS A 5 14.038 15.

Solution 1:

You have \C in the first part of the regex

r'^ATOM\s+\d+\s+\CA

you should write just CA

r'^ATOM\s+\d+\s+CA

without escaping.

Later you have the same with \T.

\X means escaped X and most of the time is a special sequence in regex, e.g. \d for a digit or \s for a whitespace.

Post a Comment for "What Causes Python Error 'bad Escape \c'?"