The pagesubs() function reads a text file into a string,then uses Python’s format() to substitute for arguments given in the subs parameter.
Here are examples:
My attempt was as follows:
def pagesubs(N,*subs):
assert type(N)==str
F= open(N,'r')
return F.format(subs)
I get an error that F is type(file) but I thought the open() reads a text file into a string. Any help is greatly appreciated
EDIT: Example
pagesubs('index.html', 'December', 18, 2012)
This will return the content of the file index.html, but
with "December" substituted for {0}, and 18 substituted
for {1}, and 2012 substituted for {2}.
You need to call the
read()function on your file in order to get it’s content into a string. Try the following code instead: