當前位置: 首頁>>代碼示例>>Python>>正文


Python Page.write_answer方法代碼示例

本文整理匯總了Python中pages.Page.write_answer方法的典型用法代碼示例。如果您正苦於以下問題:Python Page.write_answer方法的具體用法?Python Page.write_answer怎麽用?Python Page.write_answer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pages.Page的用法示例。


在下文中一共展示了Page.write_answer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

# 需要導入模塊: from pages import Page [as 別名]
# 或者: from pages.Page import write_answer [as 別名]
 def get(self):
     # create instance of the view
     p = Page()
     # create instance of the converter class
     u = MetricUnitConverter()
     # create instance of the data library class
     data = DataHolder()
     # if/ else statement to determine which view to throw
     if self.request.GET:
         # form inputs are stores in the data library
         data.name = self.request.GET['name']
         data.feet = self.request.GET['feet']
         data.inches = self.request.GET['inches']
         data.pounds = self.request.GET['weight']
         # calculations are returned to the data library
         data.meters = u.height_converter(data.feet, data.inches)
         data.kilograms = u.weight_converter(data.pounds)
         # english BMI requires height to be in inches only
         data.total_inches = u.inches_only(data.feet, data.inches)
         p.english_bmi = u.english_bmi_calculator(data.pounds, data.total_inches)
         p.metric_bmi = u.metric_bmi_calculator(data.kilograms, data.meters)
         # name is stored in the data library as well
         p.name = data.name
         # Custom message is injected into the h1 tag
         p.message = "Thanks for filling out our form!"
         # generate the results view
         self.response.write(p.write_answer())
     # else statement to hold the form view (1st view)
     else:
         # generate the form view (1st view)
         self.response.write(p.write_form())
開發者ID:mrthomasjackson,項目名稱:DPW,代碼行數:33,代碼來源:main.py


注:本文中的pages.Page.write_answer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。