<tfoot id='x9C5b'></tfoot>
      <legend id='x9C5b'><style id='x9C5b'><dir id='x9C5b'><q id='x9C5b'></q></dir></style></legend>

          <bdo id='x9C5b'></bdo><ul id='x9C5b'></ul>

        <i id='x9C5b'><tr id='x9C5b'><dt id='x9C5b'><q id='x9C5b'><span id='x9C5b'><b id='x9C5b'><form id='x9C5b'><ins id='x9C5b'></ins><ul id='x9C5b'></ul><sub id='x9C5b'></sub></form><legend id='x9C5b'></legend><bdo id='x9C5b'><pre id='x9C5b'><center id='x9C5b'></center></pre></bdo></b><th id='x9C5b'></th></span></q></dt></tr></i><div id='x9C5b'><tfoot id='x9C5b'></tfoot><dl id='x9C5b'><fieldset id='x9C5b'></fieldset></dl></div>

      1. <small id='x9C5b'></small><noframes id='x9C5b'>

        跳过python中范围函数中的值

        时间:2023-11-08

        1. <small id='dBu6S'></small><noframes id='dBu6S'>

          • <tfoot id='dBu6S'></tfoot>

            <legend id='dBu6S'><style id='dBu6S'><dir id='dBu6S'><q id='dBu6S'></q></dir></style></legend>
              • <bdo id='dBu6S'></bdo><ul id='dBu6S'></ul>
                <i id='dBu6S'><tr id='dBu6S'><dt id='dBu6S'><q id='dBu6S'><span id='dBu6S'><b id='dBu6S'><form id='dBu6S'><ins id='dBu6S'></ins><ul id='dBu6S'></ul><sub id='dBu6S'></sub></form><legend id='dBu6S'></legend><bdo id='dBu6S'><pre id='dBu6S'><center id='dBu6S'></center></pre></bdo></b><th id='dBu6S'></th></span></q></dt></tr></i><div id='dBu6S'><tfoot id='dBu6S'></tfoot><dl id='dBu6S'><fieldset id='dBu6S'></fieldset></dl></div>
                    <tbody id='dBu6S'></tbody>
                  本文介绍了跳过python中范围函数中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  循环遍历一系列数字并跳过一个值的 Python 方式是什么?例如,范围是 0 到 100,我想跳过 50.

                  What is the pythonic way of looping through a range of numbers and skipping over one value? For example, the range is from 0 to 100 and I would like to skip 50.

                  这是我正在使用的代码

                  for i in range(0, len(list)):
                      x= listRow(list, i)
                      for j in range (#0 to len(list) not including x#)
                          ...
                  

                  推荐答案

                  您可以使用以下任何一种:

                  You can use any of these:

                  # Create a range that does not contain 50
                  for i in [x for x in xrange(100) if x != 50]:
                      print i
                  
                  # Create 2 ranges [0,49] and [51, 100] (Python 2)
                  for i in range(50) + range(51, 100):
                      print i
                  
                  # Create a iterator and skip 50
                  xr = iter(xrange(100))
                  for i in xr:
                      print i
                      if i == 49:
                          next(xr)
                  
                  # Simply continue in the loop if the number is 50
                  for i in range(100):
                      if i == 50:
                          continue
                      print i
                  

                  这篇关于跳过python中范围函数中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:只需要索引:枚举还是(x)范围? 下一篇:Python:从间隔映射到值

                  相关文章

                    <bdo id='T9GXn'></bdo><ul id='T9GXn'></ul>

                  <small id='T9GXn'></small><noframes id='T9GXn'>

                    <tfoot id='T9GXn'></tfoot>
                  1. <legend id='T9GXn'><style id='T9GXn'><dir id='T9GXn'><q id='T9GXn'></q></dir></style></legend>

                    <i id='T9GXn'><tr id='T9GXn'><dt id='T9GXn'><q id='T9GXn'><span id='T9GXn'><b id='T9GXn'><form id='T9GXn'><ins id='T9GXn'></ins><ul id='T9GXn'></ul><sub id='T9GXn'></sub></form><legend id='T9GXn'></legend><bdo id='T9GXn'><pre id='T9GXn'><center id='T9GXn'></center></pre></bdo></b><th id='T9GXn'></th></span></q></dt></tr></i><div id='T9GXn'><tfoot id='T9GXn'></tfoot><dl id='T9GXn'><fieldset id='T9GXn'></fieldset></dl></div>