Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use python to program webpy framework template def with

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article introduces the knowledge of "how to use python to program webpy framework template def with". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

One: the understanding of the template

Template is the result of fixing and standardizing the structural law of a thing.

For example: the composition of the web page needs to be html,head,body, you only need to write according to its rules, how it is implemented, you need to know other knowledge.

Web.py: pages are uniformly mapped through html files and background classes, and the web framework provides a complete mechanism for html files to obtain parameters in classes.

Second: simple template

1. Create a new file html in your directory and create an index.html file in this folder

What is in the index.html:

Web simple template Hello, I'm web simple template

two。 Get the html folder I just created

Render = web.template.render ('html/') # the framework goes to the html directory to find all the html files.

3. Operate according to the name of the specific file

Render.index () # index represents the index.html I created

4. Example

Running result:

The default port is 8080. You can also change the port.

Python project name. py port number

Three: def with

1. Transfer parameters

Name=' Zhang San'

Render.index (name) # index indicates that the index.html,name I created represents how many parameter values are in the file. {parameters can be multiple}

two。 Accept parameters

Pay attention to the space problem:

Running result:

Four: pay attention

1. Port number problem

2. The problem of spaces in index.html

3. Multiple program startup problems, you may need to end multiple processes in the execution of the program

This is the end of "how to use python to program webpy framework template def with". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report