如何让otherImages返回其中的字符串,以便在从“窄”方法调用时替换其中的单词?你知道吗
def otherImages(self):
self.wfile.write(bytes("<div id='menu_button'><a href='/narrow'><img src='../images/menu_button.png'></a></div>", "utf8"))
#^word I want to replace
def contentList(self, skip_name=''): # All content methods in list
methods = [self.title, self.containerDIV, self.heading, self.stopSection, self.offlineSection, self.onlineSection, self.endDIV, self.otherImages]
for m in methods:
if m.__name__ != skip_name:
m()
def narrow(self):
try:
self.reply()
self.contentList('onlineSection') # removed onlineSection
for words in self.otherImages():
words.replace("narrow", "index")
以下是我所做的改变,解决了我的问题。它允许我在从“窄”方法调用时编辑字符串。你知道吗
self.otherImages
没有return
任何东西!当函数在python中不返回显式值时,它返回None
。不能在None
上迭代。你知道吗相关问题 更多 >
编程相关推荐