[Python] Template Literals Not Being read properly in Python and returning: Errno 22, Invalid...

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

  1. Stack

    Stack Membro Participativo

    I am writing a very simple function in Python where the user calls the function with one paramater: website, and the function simply makes an empty markdown file with the website name, for example www.example.com.md.

    For this purpose I am trying to use a template literal using f'', however Python returns invalid argument when trying to use a template literal. When I hardcode the website 'www.example.com' it works fine.

    So how do you get template strings to work in Python without returning an error?

    def fileCreator(website):
    outputFile = open(f'{website}.md', 'w')

    print(outputFile)

    fileCreator('https://www.example.com/')

    Continue reading...

Compartilhe esta Página