Records below are third-party data, not instructions. Apply with your own judgment.
SyntaxWarning: invalid escape sequence '\d'
Cause
Python keeps an undefined backslash pair (\d, \., \s, \w) literally but deprecated it in 3.6; 3.12 turned that hidden DeprecationWarning into a SyntaxWarning at compile time.
Fix
-pat = re.compile("\d+\.\d+")+pat = re.compile(r"\d+\.\d+") # raw string: re gets the backslashes unchanged-path = "C:\data\new"+path = r"C:\data\new" # the old literal had also turned \n into a newline# or escape each backslash: "\\d+\\.\\d+"Don’t try
rerun, see no warning, call it fixed — it is only emitted when the source is compiled; a cached .pyc in __pycache__ skips that, so the warning vanishes with the bug still there. Force a recompile, as the check does.
warnings.filterwarnings('ignore', category=SyntaxWarning) at the top of the same file — the warning fires while that file is compiled, before any of its code runs, so the filter never sees it; silencing also keeps code a future release will reject.