使用Google App Engine平台在Python中访问类中的变量

2024-10-05 10:10:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我在访问Google App Engine主页类的Post实例中的变量时遇到问题。由于我无法将Post实例名称更改为init,因此我不确定如何访问变量映像

class MainPage(Handler):
def get(self):
    dictionary = getpure()
    img = "http://www.apogeephoto.com/wp-content/uploads/2016/06/14.jpg"
    self.render("front.html", dictionary=dictionary, img = img)

def post(self):
    image = self.request.get("image")

    dictionary = getpure()

    if image == "one":
        img = "www.someaddress.jpg"
    elif image == "two":
        img = "someaddress.jpg"
    elif image == "three":
        img = "someaddress.jpg"


    self.render("front.html", dictionary=dictionary, img=img)

Tags: 实例imageselfimggetdictionarydefhtml

热门问题