手册
目录
注释允许您包含应该忽略的代码部分。
Welcome Everyone
{% comment %}
Welcome ladies and gentlemen
{% endcomment %}
运行实例 »
您可以在注释中添加一条消息,以帮助您记住您写注释的原因,或作为给阅读代码的其他人的消息。
为您的注释添加描述:
Welcome Everyone
{% comment "this was the original welcome message" %}
Welcome ladies and gentlemen
{% endcomment %}
运行实例 »
您还可以在注释掉代码时使用 {# ... #} 标签,这对于较小的注释会更容易阅读:
把Everyone这个词注释掉:
Welcome{# Everyone#}
运行实例 »
视图是用 Python 编写的,Python 注释是用 # 字符编写的:
注释掉视图中的一个部分:
from django.http import HttpResponse
from django.template import loader
def testing(request):
template = loader.get_template('template.html')
#context = {
# 'var1': 'John',
#}
return HttpResponse(template.render())
运行实例 »
在 Python 注释教程中了解更多关于 Python 注释的信息。
相关
视频
RELATED VIDEOS
科技资讯
1
2
3
4
5
6
7
8
9
精选课程
共5课时
17.2万人学习
共49课时
77万人学习
共29课时
61.7万人学习
共25课时
39.3万人学习
共43课时
71万人学习
共25课时
61.6万人学习
共22课时
23万人学习
共28课时
33.9万人学习
共89课时
125.1万人学习