Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the python scripting framework webpy template control structures

Shulou Source: shulou.com Published: 2022-06-02 13:16:37 09月10日 Update

This article mainly talks about "what is the control structure of python script framework webpy template". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn the "python script framework webpy template control structure" bar!

The control structure is for,while,if-else,if-elif,while. Else, in fact, in web.py as we have learned before, the operation is basically the same, but there are still some differences!

For$for row in range (10): line $row $def with (funs) $for row in funs:

Line $row

Be sure to remember here that funs do not add $

If funs is list, then some properties of $ros specific list, which you can see in while

While$while funs: $funs.pop ()

Funs is list, specific pop attribute

If-else$for row in range (10): $if row==2: I am 2$ elif row==3: I am 3$ else: $row instance

Content in index.html

$def with (fun_name Funs) web parameter template my name: use of the range function $for row in range (10): line $row my name: $fun_name $# comment $for row in funs: line $row my name: while loop $while funs: $funs.pop () my name: if-else $for row in range (10): $if row==2: I am 2$ elif row==4: I am 4$ else: $row

What is in the Python:

# coding:utf-8 import web urls= ('/', 'Index',) render = web.template.render (' html/') class Index: def funA (self): mylist= ['1', 2', 5'] return mylist def GET (self): web.header ('Content-Type','text/html) Charset=UTF-8') return render.myindex ('for cycle', (1) app=web.application (urls,globals ()) if _ _ name__ = ='_ main__': app.run ()

Results:

At this point, I believe you have a deeper understanding of the "python script framework webpy template control structure". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Templates structures controls content names frames scripts properties learning loops different practical deeper same interests functions parameters examples practicality reality Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei OPPO Reno Microsoft Redmi macOS