Hello.
I'm an engineer who just started Python. It's an easy question because I'm a beginner I don't understand, so I'm uploading it here.
First of all, the logic is like this.
It's this simple logic, where I did everything, but the blockage is to table the row that I read.
I read and send e-mails, read and send e-mails when I turn the for door. I want to send this bread at once... No matter how many times I try the list...I don't know even if I create an array.
It's a basic question, but I'm looking for it I'm posting it because I don't understand.
Thank you.
html python
Try the template.
pip install jinja2
template.html file
{% macro yhjung(data) -%}
<div>{{ data | addNum}}</div>
{%- {%- endmacro%}
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional/EN">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body>
{% {% for data in datas -%}
{{ {{ yhjung(data) }}
{% {% endfor %}
<div>{{ clever_function() }}</div>
</body>
</html>
Python files
import os
from jinja2 import Environment, FileSystemLoader
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
j2_env = Environment(loader=FileSystemLoader(THIS_DIR))
def addNum(value):
return int(value) + 2
def clever_function():
return "HELLO"
def main():
contents = j2_env.get_template('template.html').render(datas=range(10), clever_function=clever_function)
print(contents)
if __name__ == "__main__":
j2_env.filters["addNum"] = addNum
main()
Try putting the Python and template files in the same directory and running the Python files.
© 2024 OneMinuteCode. All rights reserved.