[Python] Has handling of escape characters in quoted strings changed between Python 3.10 and...

Discussão em 'Python' iniciado por Stack, Maio 24, 2025.

  1. Stack

    Stack Membro Participativo

    I have a program that works under Python 3.10.2 Windows that contains a line like this:

    outfilename = outpathname+"\cfile.txt"


    outfilename ends up looking like c:\some\path\cfile.txt"

    This code runs clean on 3.10.2.

    I moved this code to another Windows system running Python 3.13.3

    It generates syntax warnings:

    C:\PythonCode\something.py:184: SyntaxWarning: invalid escape sequence '\c'
    outfilename = outpathname+"\cfile.txt"


    I didn't find any relevant details searching on "escape" in 3.13 changes. Is this a significant change? Should I have been using "\\c" to escape the "\" in the quoted string all along and now a warning has been added?

    Continue reading...

Compartilhe esta Página