1

This time I need to know how can I use python variable to create a href link in html which is part of a python script.

For instance,

LinkX = "file://///server/folderX 

where folderX changes all the time and then to use this LinkX as a part of

<a href = "folderX">LinkX</a>. 

Something like this. Thank you.

1

2 Answers 2

3

If you are generating the html as text, you can use string formatting:

link = '<a href="{0}">{1}</a>'.format(destination, description)
Sign up to request clarification or add additional context in comments.

1 Comment

It should be a link which is sent via email with python.
1

Something like this?

>>> linkUrl = 'file://///server/folderX'
>>> linkText = '<a href="{}">{}</a>'.format(linkUrl, 'Folder X')
>>> linkText
'<a href="file://///server/folderX">Folder X</a>'

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.