I need to insert a formula into Excel using Python.  I am creating a dataframe and adding a column containing the formulas and then writing it into an Excel.
The formula has the format '=HYPERLINK("#'"&F2&"'!A1",F2)'
F2 is a variable and all other characters are constant.  I need to dynamically generate this string. 
I tried doing =HYPERLINK("#'"&F2&"'!A1",F2) but it is not working and I got '=HYPERLINK("#\'"&F2&"\'!A1",F2)' which includes the back slash and the formula does not work.
How do I create a string like '=HYPERLINK("#'"&F2&"'!A1",F2)' ?
Any help would be highly appreciated.
Since you are making string dynamically. There are two things you can do.

r'=HYPERLINK("#'"&F2&"'!A1",F2)' r signifies raw string (if you are not using any variable).
If you are making string dynamically using other variables. Use formatted string.
var1= '"#'"&F2&"'!A1"'
var2= 'F2'
formula= f'=HYPERLINK({var1},{var2} )'


print(formula)
'=HYPERLINK("#&F2&!A1",F2 )'
Create a string with single and double quotes