• <small id='dCYh7'></small><noframes id='dCYh7'>

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

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

        Python:十进制数的范围函数

        Python: range function for decimal numbers(Python:十进制数的范围函数)

        • <small id='hX56v'></small><noframes id='hX56v'>

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

                <tbody id='hX56v'></tbody>

                  <tfoot id='hX56v'></tfoot>
                • <legend id='hX56v'><style id='hX56v'><dir id='hX56v'><q id='hX56v'></q></dir></style></legend>
                  本文介绍了Python:十进制数的范围函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  python中有没有用于浮点数的range()函数例如

                  Is there any range() function in python for float numbers for example

                  a=0.6
                  
                  if a in range(0,1):
                      a=3
                  

                  我该如何实现?

                  推荐答案

                  如果我没看错,你想测试一个数字是否在另外两个数字之间,所以使用:

                  If I'm reading correctly, you want to test if a number is between two other numbers, so use:

                  a = 0.6
                  if 0 <= a < 1: # change to `<= 1` to be inclusive
                     a = 3
                  

                  您不需要生成范围并进行成员资格测试 - 除非您有一组离散值,您的 a 应该匹配 - Python 中的内置 range3.x 可以对 int 进行有效的查找,因为它可以优化成员资格测试.如果你在一个很大的范围内有大量的离散值,那么你最好还是用数学方法来做.

                  You don't need to generate a range and do membership testing - unless you have a discrete set of values that your a should match - the builtin range in Python 3.x can do efficient lookups for ints as it can optimise membership testing. If you have a large amount of discrete values in a large range, then you'd be better of doing it mathematically anyway.

                  这篇关于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中的另一个文件中查找一个文本文件的条目)
                • <legend id='72iDX'><style id='72iDX'><dir id='72iDX'><q id='72iDX'></q></dir></style></legend>
                • <small id='72iDX'></small><noframes id='72iDX'>

                  • <tfoot id='72iDX'></tfoot>
                      <bdo id='72iDX'></bdo><ul id='72iDX'></ul>

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