码迷,mamicode.com
首页 > 其他好文 > 详细

for循环实现九九乘法表

时间:2018-09-20 00:57:59      阅读:449      评论:0      收藏:0      [点我收藏+]

标签:退出   com   div   http   break   nbsp   实现   code   --   

    <!--for循环实现九九乘法表-->
    <table border="1">
        <tbody>
            {% for x in range(1,10) %}
                <tr>
                    {% for y in range(1,x + 1) %}
                        <td>
                            {{ y }} * {{ x }} = {{ y * x }}
                        </td>
                    {% endfor %}

                </tr>
            {% endfor %}
        </tbody>
    </table>
    <!--for循环的另一种实现-->
      <table border="1">
        <tbody>
            {% for x in range(1,10) %}
                <tr>
                    <!--for模板中不能用continue和break-->
                    <!--但是可以加 if条件实现同样的功能-->
                    {% for y in range(1,10) if y <= x %}
                    <!--if 条件为false,循环退出-->
                        <td>
                            {{ y }} * {{ x }} = {{ y * x }}
                        </td>
                    {% endfor %}

                </tr>
            {% endfor %}
        </tbody>
    </table>

技术分享图片

 

for循环实现九九乘法表

标签:退出   com   div   http   break   nbsp   实现   code   --   

原文地址:https://www.cnblogs.com/wuheng-123/p/9678335.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!