<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中范围函数中的值

        Skip over a value in the range function in python(跳过python中范围函数中的值)

        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中范围函数中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  What happens when you compare 2 pandas Series(当你比较 2 个 pandas 系列时会发生什么)
                  Quickly find differences between two large text files(快速查找两个大文本文件之间的差异)
                  Python - Compare 2 files and output differences(Python - 比较 2 个文件和输出差异)
                  Why do comparisions between very large float values fail in python?(为什么在 python 中非常大的浮点值之间的比较会失败?)
                  Dictionary merge by updating but not overwriting if value exists(字典通过更新合并,但如果值存在则不覆盖)
                  Find entries of one text file in another file in python(在python中的另一个文件中查找一个文本文件的条目)

                        <tbody id='T9GXn'></tbody>
                        <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>