[Python] How to import from filename that starts with a number

Discussão em 'Python' iniciado por Stack, Janeiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    Basically there is a file called 8puzzle.py and I want to import the file into another file (in the same folder and I cannot change the file name as the file is provided). Is there any way to do this in Python? I tried usual way from 8puzzle import *, it gives me an error.

    Error is:

    >>> import 8puzzle
    File "<input>", line 1
    import 8puzzle
    ^
    SyntaxError: invalid syntax
    >>>

    Continue reading...

Compartilhe esta Página