2
我想爲html/javascript模板做一些字符串替換,但是當頁面字符串變量在代碼中有大括號時,出現「ValueError:unsupported格式字符'}'(0x7d)「。如果我沒有任何字符串替換,一切正常。謝謝閱讀!字符串替換 - 不受支持的格式字符'}'
import webapp2
page = """
<html>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
#map_canvas { height: 100% }
</style>
%(say)s
</html>
"""
class MainHandler(webapp2.RequestHandler):
def write_form(self, say):
self.response.out.write(page % { "say": say })
def get(self):
self.write_form("hello")
app = webapp2.WSGIApplication([('/', MainHandler)],
debug=True)