该pagesubs()
函数将文本文件读入字符串,然后使用 Pythonformat()
替换 subs 参数中给出的参数。
以下是示例:
我的尝试如下:
def pagesubs(N,*subs):
assert type(N)==str
F= open(N,'r')
return F.format(subs)
我收到一个错误,F is type(file)
但我认为将open()
文本文件读入字符串。任何帮助是极大的赞赏
编辑:示例
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}.