1

I am trying to write a function in Python, that concatenates path + filename:

import os 

ruta_proyecto = os.path.dirname(os.path.abspath(__file__))

def ejecutar_sql(archivo, parametro):
    sp.ejecutar_archivo(f"{ruta_proyecto}{archivo}", parametro)

But if I try to add "/ invert* " in the function, it returns an error.

How can I concatenate {ruta_proyecto} + "/ invert"* + {archivo}.

sjaustirni
  • 3,056
  • 7
  • 32
  • 50

1 Answers1

2

Thanks to the comments of Barmar and Olvin Roght, I have resolved the problem. This is the answer:

def ejecutar_sql(archivo, parametro):
     sp.ejecutar_archivo(os.path.join(os.path.dirname(os.path.abspath(__file__)),f'{archivo}' ), parametro)
ZygD
  • 22,092
  • 39
  • 79
  • 102