[Python] Python - ConfigParser and pathlib Path WindowsPath

Discussão em 'Python' iniciado por Stack, Agosto 8, 2025.

  1. Stack

    Stack Membro Participativo

    I am reading a configuration file with ConfigParser. Until now, I was storing the paths to my files as str. I decided to improve my code by using Path from pathlib.

    I now have the following error: configparser.NoSectionError: No section:. I understand from this answer that the error comes from my WindowsPath having backslashes.

    Question: How can I path a WindowsPath to ConfigParser without throwing an error?

    Continue reading...

Compartilhe esta Página