0

I'm writing an python script which generates html reports. So far OK. Now I'm on a point where I would like to have variable names of a file within a link. This means i have a directory with files of following names:

LOG_file1.txt
LOG_file2.txt

LOG_file3.txt

LOG_file4.txt

LOG_file5.txt

As you can see, the file names begins with "LOG_" and ends with ".txt"

Now I would like to build a link depending on the needed file. For example if I have a variable "filename" in my python script (which is defined earlier) where the name of the file is stored (file1, file2, file3...). At the end would like to have something like this:

<a href="this/is/the/path/to/my/LOG_filename.txt">My Link</a>

where "filename" is one of the files listed below. I have tried this:

'<a href="this/is/the/path/to/my/LOG_'+filename'+'.txt'\"> My Link </a>' 

Have also to mention that i'm relatively new to python.

1 Answer 1

1
'<a href="this/is/the/path/to/my/LOG_%s.txt">My Link</a>' % filename
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.