模板引擎语法-标签

news2025/4/14 20:59:26

模板引擎语法-标签

文章目录

  • 模板引擎语法-标签
    • @[toc]
    • 一、用于进行判断的{% if-elif-else-endif %}标签
    • 二、关于循环对象的{% for-endfor %}标签
    • 三、关于自动转义的{% autoescape-endautoescape %}标签
    • 四、关于循环对象的{% cycle %}标签
    • 五、关于检查值是否变化的{% ifchange %}标签
    • 六、关于重组对象的{% regroup %}标签
    • 七、关于重置循环对象的{% resetcycle %}标签
    • 八、{% url %}链接标签
    • 九、输出模板标签字符的{% templatetag %}标签
    • 十、关于计算比率的{% widthratio %}标签
    • 十一、关于显示当前日期或时间的{% now %}标签

一、用于进行判断的{% if-elif-else-endif %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['t'] = "true"
    context['f'] = "false"
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

代码分析
context[‘t’] = “true”在变量context中定义了第一个属性t,并赋值为字符串“true”
context[‘f’] = “false”在变量context中定义了第一个属性f,并赋值为字符串“false”

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    <b>if-elif-else-endif</b><br><br>
    True:
    {% if t == 'true' %}
        This is a true condition.
    {% elif t == 'false' %}
        This is a false condition.
    {% else %}
        No condition.
    {% endif %}
    <br><br>
    False:
    {% if f == 'true' %}
        This is a true condition.
    {% elif f == 'false' %}
        This is a false condition.
    {% else %}
        No condition.
    {% endif %}
    <br><br>
    No Else:
    {% if f == 'true' %}
        This is a true condition.
    {% elif t == 'false' %}
        This is a false condition.
    {% else %}
        No condition.
    {% endif %}
    <br><br>
</p>

</body>
</html>

【代码分析】

修改的内容,分别通过标签进行选择判断,根据判断结果选择输出不同的文本信息。

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述


二、关于循环对象的{% for-endfor %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['flag'] = "odd"    # "even" or "odd"
    context['even'] = [0, 2, 4, 6, 8]
    context['odd'] = [1, 3, 5, 7, 9]
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在修改的内容中,在变量context中添加了第一个属性flag,并赋值为“even”;

在变量context中添加了第二个属性even,并赋值为也给偶数列表(数字10以内);

在变量context中添加了第三个属性odd,并赋值为一个奇数列表(数字10以内);

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    Numbers:
    <ul>
        {% if flag == 'even' %}
            {% for num in even %}
                <li>{{ num }}</li>
            {% endfor %}
        {% elif flag == 'odd' %}
            {% for num in odd %}
                <li>{{ num }}</li>
            {% endfor %}
        {% else %}
            No print.
        {% endif %}
    </ul>
</p>

</body>
</html>

【代码分析】

通过标签进行选择判断,根据判断结果选择输出奇数数列或偶数数列。

分别通过标签循环对象even和odd,输出奇数数列和偶数数列。

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述
在这里插入图片描述


三、关于自动转义的{% autoescape-endautoescape %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['site'] = "<a href='https://www.djangoproject.com/'>Django Home Page</a>"
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在变量context中添加了一个属性site,并赋值为一个超链接标签"Django Home Page"

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    Escape Site:
    <br><br>
    output site:<br>
    {{ site }}
    <br><br>
    autoescape on :<br>
    {% autoescape on %}
        {{ site }}
    {% endautoescape %}
    <br><br>
    autoescape off :<br>
    {% autoescape off %}
        {{ site }}
    {% endautoescape %}
</p>

</body>
</html>

【代码分析】

通过双大括号引用了视图定义的属性,直接在页面中进行输出;

分别通过【{% autoescape on %}】【{% endautoescape %}】自动转义标签对属性site进行打开转义操作,并在页面中进行输出;

分别通过【{% autoescape on %}】【{% endautoescape %}】自动转义标签对属性site进行关闭转义操作,并在页面中进行输出;

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述


四、关于循环对象的{% cycle %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['num'] = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在变量context中添加了一个属性num,并赋值为一个元组类型的数组(用于计数);

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p class="middle">
    Cycle Obj:<br>
    {% for i in num %}
        {% cycle 'even' 'odd' %}
    {% endfor %}
</p>

</body>
</html>

【代码分析】

通过【{% cycle %}】循环对象标签对一组字符串进行循环遍历操作,并在页面中直接输出

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

4.继续编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['len'] = (0, 1, 2)
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在变量context中添加了一个属性len,并赋值为一个元组类型的数组(用于计数);

5.继续编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    Cycle Paragraphs:<br>
    {% for j in len %}
        <p class="{% cycle 'p-small' 'p-middle' 'p-large' %}">
            This is a cycle class test.
        </p>
    {% endfor %}
</p>

</body>
</html>

【代码分析】

通过【{% cycle %}】循环对象标签对一组CSS样式表进行循环遍历操作,这组不同的样式均内置于同一个段落标签;

6.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

五、关于检查值是否变化的{% ifchange %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['num'] = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
    context['changed'] = 'watchchange'
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在变量context中添加了一个属性changed,并赋值为一个字符串,用于判断内容是否改变;

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p class="middle">
    ifchanged:<br>
    {% for n in num %}
        {% ifchanged changed %}
            {{ n }}
        {% endifchanged %}
    {% endfor %}
</p>

</body>
</html>

【代码分析】

通过【{% ifchanged-endifchanged %}】标签判断属性changed的内容是否改变;

并根据上面判断的结果来输出变量n的值;

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

4.继续编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p class="middle">
    ifchanged:<br>
    {% for n in num %}
        {% ifchanged changed %}
            {{ n }}
        {% else %}
            {{ n }}
        {% endifchanged %}
    {% endfor %}
</p>

</body>
</html>

【代码分析】

在【{% ifchanged-endifchanged %}】标签中增加了{% else %}标签。

同样在输出变量n的值;

5.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

六、关于重组对象的{% regroup %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['languages'] = [
        {'name': 'Python', 'rated': '99%', 'content': 'Prog'},
        {'name': 'Java', 'rated': '90%', 'content': 'Prog'},
        {'name': 'JavaScript', 'rated': '98%', 'content': 'Web'},
        {'name': 'PHP', 'rated': '95%', 'content': 'Web'},
        {'name': 'Django', 'rated': '96', 'content': 'Web'},
    ]
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在变量context中添加了一个属性languges,并赋值为一个字典类型的数组(关于几组编程语言的内容);

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
{% regroup languages by content as content_list %}
<p>
    regroup tag:<br>
    <ul>
        {% for content in content_list %}
            <li>{{ content.grouper }}
                <ul>
                    {% for lang in content.list %}
                        <li>{{ lang.name }}: {{ lang.rated }}</li>
                    {% endfor %}
                </ul>
            </li>
        {% endfor %}
    </ul>
</p>

</body>
</html>

【代码分析】

通过grouper字段来依据content属性对languages对象列表进行分组;

通过list字段来获取每一项的列表,该列表包括了languages对象中每一项的具体内容;

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

七、关于重置循环对象的{% resetcycle %}标签

1.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['len'] = (0, 1, 2)
    context['len2'] = (0, 1, 2, 3)
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

【代码分析】

在变量context中添加了一个属性len,并赋值为一个元组类型的变量(用于第一层循环计数);

在变量context中添加了一个属性len2,并赋值为另一个元组类型的变量(用于第二层循环计数);

2.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    Cycle Numbers:<br>
    {% for i in len %}
        {% for j in len2 %}
            {% cycle '1' '2' '3' %}
        {% endfor %}
    {% endfor %}
</p>
<p>
    Resetcycle Numbers:<br>
    {% for i in len %}
        {% for j in len2 %}
            {% cycle '1' '2' '3' %}
        {% endfor %}
        {% resetcycle %}
    {% endfor %}
</p>

</body>
</html>

【代码分析】

通过{% cycle %}标签尝试在页面输出一个数字序列;

同样通过{% cycle %}标签尝试在页面输出一个数字序列;

不同之处是在27行中,通过{% resetcycle %}标签重置了第25行代码中的{% cycle %}标签。

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述


八、{% url %}链接标签

1.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    url tag:<br><br>
    <a href={% url 'index' %}>index</a><br><br>
    <a href={% url 'grammar' %}>grammar</a><br><br>
</p>

</body>
</html>

【代码分析】

通过{% url %}链接标签定义了视图index的超链接地址;

同样通过{% url %}链接标签定义了视图grammar的超链接地址;

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

4.编辑路由文件

文件路径【TmplSite/gramapp/urls.py】

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
    path('gram/', views.grammar, name='grammar'),
    path('gram/<gram_id>/', views.grammar_id, name='grammar_id'),
]

【代码分析】

表示路径gram_id对应视图函数grammar_id,其中gram_id表示路径参数;

5.编辑视图文件

文件路径【TmplSite/gramapp/views.py】

from django.http import HttpResponse
from django.shortcuts import render
from django.template import loader


# Create your views here.

def index(request):
    return HttpResponse("Hello, Django! You're at the gramapp index.")

def grammar(request):
    context = {}
    context['title'] = "Django Template Grammar"
    context['gram'] = "grammar"
    context['id'] = '123'
    template = loader.get_template('gramapp/grammar.html')
    return HttpResponse(template.render(context, request))

def grammar_id(request, gram_id):
    return HttpResponse("Hello, you're at the grammar %s index." % (gram_id))

【代码分析】

定义了一个视图函数grammar_id,并包括一个参数gram_id;

在变量context中添加了一个属性id,并赋值为一个字符串“123”;

6.继续编辑模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    url tag:<br><br>
    <a href={% url 'grammar_id' id %}>grammar_id</a><br><br>
    <a href={% url 'grammar_id' gram_id=id %}>grammar_id(by arg1)</a><br><br>
</p>

</body>
</html>

【代码分析】

通过{% url %}链接标签定义了视图grammar_id的超链接地址,并使用了id参数;

同样通过{% url %}链接标签定义了视图grammar_id的超链接地址,在使用id参数的方式上借助了关键字参数gram_id

7.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

九、输出模板标签字符的{% templatetag %}标签

1.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    templatetag openblock:<br>
    {% templatetag openblock %} {% url 'grammar' %} {% templatetag closeblock %}<br><br>
    templatetag openvariable:<br>
    {% templatetag openvariable %} {{ num }} {% templatetag closevariable %}<br><br>
    templatetag openbrace:<br>
    {% templatetag openbrace %} {{ len }} {% templatetag closebrace %}<br><br>
</p>
</body>
</html>

【代码分析】

通过{% templatetag openblock %}标签和{% templatetag closeblock %}标签在页面中输出了语法字符“{% %}”;

通过{% templatetag openvariable %}标签和{% templatetag closevariable %}标签在页面中输出了语法字符“{{ }}”;

通过{% templatetag openbrace %}标签和{% templatetag closebrace %}标签在页面中输出了语法字符“{ }”;

2.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】
在这里插入图片描述

十、关于计算比率的{% widthratio %}标签

1.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    image original:<br><br>
    <img src="/static/images/django-small.png" alt="Django">
</p>
<p>
    image widthradio:<br><br>
    <img src="/static/images/django-small.png" alt="Django" height="{% widthratio 100 50 100 %}" width="{% widthratio 180 200 100 %}">
</p>
</body>
</html>

【代码分析】

在HTML模板中显示了一幅原始图片(图片路径:“/static/images/django-small.png”);

在HTML模板页面中通过{% widthratio %}标签将该原始图片(图片路径:“/static/images/django-samll.png”)转换为柱状图进行显示;

在图片的height属性中通过{% widthratio %}标签对图片高度尺寸进行了比率换算(100÷50×100=200);

在图片的width属性中通过{% widthratio %}标签对图片宽度尺寸进行了比率换算(180÷200×100=90);

2.定义根目录settings.py文件

STATIC_URL = 'static/'

STATICFILES_DIRS = [
    BASE_DIR / "static",
]

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

十一、关于显示当前日期或时间的{% now %}标签

1.编辑HTML模板文件

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="/static/css/mystyle.css"/>
    <title>{{ title }}</title>
</head>
<body>

<p>
    Hello, this is a <b>{{ gram }}</b> page!
</p>
<p>
    now tag:<br><br>
    It is {% now "jS F Y H:i" %}<br><br>
    It is the {% now "jS \o\f F Y" %}<br><br>
    It is {% now "H:i:s D Y/M/d" %}<br><br>
</p>
</body>
</html>

【代码分析】

在HTML模板中使用{% now %}标签显示了一组时间格式;

3.打开FireFox浏览器访问

【http://localhost:8000/gramapp/gram/】

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2334006.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

深度学习学习笔记

目录 摘要 Abstracts 简介 Hourglass Module&#xff08;Hourglass 模块&#xff09; 网络结构 Intermediate Supervision&#xff08;中间监督&#xff09; 训练过程细节 评测结果 摘要 本周阅读了《Stacked Hourglass Networks for Human Pose Estimation》&#xf…

当Browser Use遇见A2A:浏览器自动化与智能体协作的“冰与火之歌“

——一场正在改写数字文明的技术奇遇 第一章 浏览器革命&#xff1a;从"手动挡"到"自动驾驶" 1.1 传统自动化工具的"中年危机" 还记得2023年那个抓狂的凌晨吗&#xff1f;你蹲守演唱会门票时&#xff0c;Selenium脚本因为验证码识别失败第108次…

(已解决)如何安装python离线包及其依赖包 2025最新

字数 305&#xff0c;阅读大约需 2 分钟 没有网络的Linux服务器上&#xff0c;如何安装完整的、离线的python包 1. 写入待安装的包 新建requirement.txt, 写入待安装的包 和 包的版本 如 flwr1.13.0 2.使用命令行直接下载 pip download -d flwr_packages -r requirements.tx…

豪越赋能消防安全管控,解锁一体化内管“安全密码”

在消防安全保障体系中&#xff0c;内部管理的高效运作是迅速、有效应对火灾及各类灾害事故的重要基础。豪越科技凭借在消防领域的深耕细作与持续创新&#xff0c;深入剖析消防体系内部管理的痛点&#xff0c;以自主研发的消防一体化安全管控平台&#xff0c;为行业发展提供了创…

拓扑排序 —— 2. 力扣刷题207. 课程表

题目链接&#xff1a;https://leetcode.cn/problems/course-schedule/description/ 题目难度&#xff1a;中等 相关标签&#xff1a;拓扑排序 / 广度优先搜搜 BFS / 深度优先搜索 DFS 2.1 问题与分析 2.1.1 原题截图 2.1.2 题目分析 首先&#xff0c;理解题目后必须马上意识到…

【STM32】ST7789屏幕驱动

目录 CubeMX配置 配置SPI 开DMA 时钟树 堆栈大小 Keil工程配置 添加两个group 添加文件包含路径 驱动编写 写单字节函数 写字函数 写多字节函数 初始化函数 设置窗口函数 情况一&#xff1a;正常的0度旋转 情况二&#xff1a;顺时针90度旋转 情况三&#xff1…

10min速通Linux文件传输

实验环境 在Linux中传输文件需要借助网络以及sshd&#xff0c;我们可通过systemctl status sshd来查看sshd状态 若服务未开启我们可通过systemctl enable --now sshd来开启sshd服务 将/etc/ssh/sshd_config中的PermitRootLogin 状态修改为yes 传输文件 scp scp &#xff08;Sec…

dify windos,linux下载安装部署,提供百度云盘地址

dify1.0.1 windos安装包百度云盘地址 通过网盘分享的文件&#xff1a;dify-1.0.1.zip 链接: 百度网盘 请输入提取码 提取码: 1234 dify安装包 linux安装包百度云盘地址 通过网盘分享的文件&#xff1a;dify-1.0.1.tar.gz 链接: 百度网盘 请输入提取码 提取码: 1234 1.安装…

使用 TFIDF+分类器 范式进行企业级文本分类(二)

1.开场白 上一期讲了 TF-IDF 的底层原理&#xff0c;简单讲了一下它可以将文本转为向量形式&#xff0c;并搭配相应分类器做文本分类&#xff0c;且即便如今的企业实践中也十分常见。详情请见我的上一篇文章 从One-Hot到TF-IDF&#xff08;点我跳转&#xff09; 光说不练假把…

《车辆人机工程-汽车驾驶操纵实验》

汽车操纵装置有哪几种&#xff0c;各有什么特点 汽车操纵装置是驾驶员直接控制车辆行驶状态的关键部件&#xff0c;主要包括以下几种&#xff0c;其特点如下&#xff1a; 一、方向盘&#xff08;转向操纵装置&#xff09; 作用&#xff1a;控制车辆行驶方向&#xff0c;通过转…

python高级编程一(生成器与高级编程)

@TOC 生成器 生成器使用 通过列表⽣成式,我们可以直接创建⼀个列表。但是,受到内存限制,列表容量肯定是有限的。⽽且,创建⼀个包含100万个元素的列表,不仅占⽤很⼤的存储空间,如果我们仅仅需要访问前⾯⼏个元素,那后⾯绝⼤多数元素占 ⽤的空间都⽩⽩浪费了。所以,如果…

单片机Day05---动态数码管显示01234567

一、原理图 数组索引段码值二进制显示内容00x3f0011 1111010x060000 0110120x5b0101 1011230x4f0100 1111340x660110 0110450x6d0110 1101560x7d0111 1101670x070000 0111780x7f0111 1111890x6f0110 11119100x770111 0111A110x7c0111 1100B120x390011 1001C130x5e0101 1110D140…

muduo库源码分析: One Loop Per Thread

One Loop Per Thread的含义就是&#xff0c;一个EventLoop和一个线程唯一绑定&#xff0c;和这个EventLoop有关的&#xff0c;被这个EventLoop管辖的一切操作都必须在这个EventLoop绑定线程中执行 1.在MainEventLoop中&#xff0c;负责新连接建立的操作都要在MainEventLoop线程…

MCP结合高德地图完成配置

文章目录 1.MCP到底是什么2.cursor配置2.1配置之后的效果2.2如何进行正确的配置2.3高德地图获取key2.4选择匹配的模型 1.MCP到底是什么 作为学生&#xff0c;我们应该如何认识MCP&#xff1f;最近看到了好多跟MCP相关的文章&#xff0c;我觉得我们不应该盲目的追求热点的技术&…

重读《人件》Peopleware -(5)Ⅰ管理人力资源Ⅳ-质量—若时间允许

20世纪的心理学理论认为&#xff0c;人类的性格主要由少数几个基本本能所主导&#xff1a;生存、自尊、繁衍、领地等。这些本能直接嵌入大脑的“固件”中。我们可以在没有强烈情感的情况下理智地考虑这些本能&#xff08;就像你现在正在做的那样&#xff09;&#xff0c;但当我…

文献总结:AAAI2025-UniV2X-End-to-end autonomous driving through V2X cooperation

UniV2X 一、文章基本信息二、文章背景三、UniV2X框架1. 车路协同自动驾驶问题定义2. 稀疏-密集混合形态数据3. 交叉视图数据融合&#xff08;智能体融合&#xff09;4. 交叉视图数据融合&#xff08;车道融合&#xff09;5. 交叉视图数据融合&#xff08;占用融合&#xff09;6…

制造一只电子喵 (qwen2.5:0.5b 微调 LoRA 使用 llama-factory)

AI (神经网络模型) 可以认为是计算机的一种新的 “编程” 方式. 为了充分利用计算机, 只学习传统的编程 (编程语言/代码) 是不够的, 我们还要掌握 AI. 本文以 qwen2.5 和 llama-factory 举栗, 介绍语言模型 (LLM) 的微调 (LoRA SFT). 为了方便上手, 此处选择使用小模型 (qwen2…

Redis核心功能实现

前言 学习是个输入的过程&#xff0c;在进行输入之后再进行一些输出&#xff0c;比如写写文章&#xff0c;笔记&#xff0c;或者做一些技术串讲&#xff0c;虽然需要花费不少时间&#xff0c;但是好处很多&#xff0c;首先是能通过输出给自己的输入带来一些动力&#xff0c;然…

【连载3】基础智能体的进展与挑战综述

基础智能体的进展与挑战综述 从类脑智能到具备可进化性、协作性和安全性的系统 【翻译团队】刘军(liujunbupt.edu.cn) 钱雨欣玥 冯梓哲 李正博 李冠谕 朱宇晗 张霄天 孙大壮 黄若溪 2. 认知 人类认知是一种复杂的信息处理系统&#xff0c;它通过多个专门的神经回路协调运行…

MacOs java环境配置+maven环境配置踩坑实录

oracl官网下载jdk 1.8的安装包 注意可能需要注册&#xff01;&#xff01;&#xff01; 下载链接&#xff1a;下载地址点击 注意晚上就不要下载了 报错400 &#xff01;&#xff01;&#xff01; 1.点击安装嘛 2.配置环境变量 export JAVA_HOME/Library/Java/Java…