1
我有這個類:IF語句導致內部服務器錯誤與webpy
class View(object):
def main_page(self, extra_placeholders = None):
file = '/media/Shared/sites/www/subdomains/pypular/static/layout.tmpl'
placeholders = { 'site_name' : 'pypular' }
# If we passed placeholders vars, append them
if extra_placeholders != None:
for k, v in extra_placeholders.iteritems():
placeholders[k] = v
我的代碼中的問題上面是if語句
正如你可以看到,該函數接受一個參數(extra_placeholders)這是一個字典。
如果我不將參數傳遞給main_page(),
if extra_placeholders == None:
return 'i executed'
運行正常。然而,
if extra_placeholders != None:
return 'i cause error'
不起作用。它會導致500內部服務器錯誤。爲什麼?
謝謝。 「不是沒有」似乎也做到了。 – sqram 2009-09-07 07:02:29
並感謝您的鏈接。真的澄清了一些事情! – sqram 2009-09-07 07:09:51
這是一個很好的例子,爲什麼外部鏈接可能有幫助,但最相關的信息應該被複制到答案中......因爲鏈接不再可用。 – kmarsh 2017-02-24 14:02:07