Create Function To Replace Index In String With Index In List, Then Save Those Values Into An Html File.
Ok so basically I have a csv file with different values. I want each line from the csv needs to create a new html file. Each value in the line of the csv needs to replace the val
Solution 1:
Python passes parameters by a scheme they refer to as "Call-By-Object." When you reassign the string in your replacehtml function, this doesn't change the original html string because strings are an immutable type.
Fastest fix is probably to change the string to a return of the function.
def replacehtml(html, somelist):
html = html.replace("VALUE1", somelist[0])
html = html.replace("VALUE2", somelist[1])
html = html.replace("VALUE3", somelist[2])
print somelist[1]
return html
html = replacehtml(html, southfile[0])
Post a Comment for "Create Function To Replace Index In String With Index In List, Then Save Those Values Into An Html File."