Python 移除0.01至0.99范围内的所有浮子

Python 移除0.01至0.99范围内的所有浮子,python,Python,我有一个简单的python程序 除法后,它显示结束值,但我不想显示.01 from __future__ import division number = int(133) output = float(0) divideNumber = int(1) stop = false while stop == false halfNumber = number / 2 output = number / divideNumber output = round(output,

我有一个简单的python程序

除法后,它显示结束值,但我不想显示.01

from __future__ import division

number = int(133)
output = float(0)
divideNumber = int(1)

stop = false

while stop == false
   halfNumber = number / 2
  output =  number / divideNumber 
  output = round(output, 2)

  if ".0" in str(output):
    if "0.1" in str(output) or "0.2" in str(output ) or.... "0.9" in str(output): 
      #Do Nothing
  else: 
      #Do Nothing
    else: 
      print str(number) + " / " + divideNumber + " = "str(output)

  divideNumber += 1

  if divideNumber < halfNumber:
    break
  else: 
    #Do Nothing
print "Goodbye"
再见

我的预期结果是

 133 / 1 = 133.0
 133 / 7 = 19.0
 133 / 19 = 7.0
 Goodbye
我的“如果”陈述错了吗?我没有收到任何错误

“我有一个简单的python程序”

这不是一个简单的程序

如果要使用一个十进制数字显示结果,请使用以下命令:

print '{:.1f}'.format(133./19.)
这张照片

7.0
如果要测试一个整数数字是否除以另一个:

if not x%y:
    # y divides x
“我有一个简单的python程序”

这不是一个简单的程序

如果要使用一个十进制数字显示结果,请使用以下命令:

print '{:.1f}'.format(133./19.)
这张照片

7.0
如果要测试一个整数数字是否除以另一个:

if not x%y:
    # y divides x

您可以定义这样的函数,例如
133.0==133
True
: :

\uuuuuuuuuuuuuuuuuuuuuu
导入的
分部

In [14]: from __future__ import division

In [15]: def func(x,y):
    return x/y == int(x/y)
   ....: 

In [16]: func(133,1)
Out[16]: True

In [17]: func(133,11)
Out[17]: False

In [18]: func(133,12)
Out[18]: False

In [19]: func(133,19)
Out[19]: True

您可以定义这样的函数,例如
133.0==133
True
: :

\uuuuuuuuuuuuuuuuuuuuuu
导入的
分部

In [14]: from __future__ import division

In [15]: def func(x,y):
    return x/y == int(x/y)
   ....: 

In [16]: func(133,1)
Out[16]: True

In [17]: func(133,11)
Out[17]: False

In [18]: func(133,12)
Out[18]: False

In [19]: func(133,19)
Out[19]: True

如果我没弄错的话,你需要跳过所有非整数的数字。此检查应类似于:

from math import floor

if (output - floor(output))>0: # skip
    continue

如果我没弄错的话,你需要跳过所有非整数的数字。此检查应类似于:

from math import floor

if (output - floor(output))>0: # skip
    continue

我也希望它能让其他人看到。我希望它能显示“133/1=133.0 133/7=19.0 133/19=7.0再见”,我也希望它能显示其他的。我更希望它显示“133/1=133.0 133/7=19.0 133/19=7.0再见”上面的代码有许多问题,其中最重要的问题是while循环应该说“while stop==False:”。另外,不需要说int(133),只需要说133。不需要说float(0),比如说0.0。上面的代码有很多问题,其中最重要的问题是while循环应该说'whilestop==False:'。另外,不需要说int(133),只需要说133。不需要说float(0),比如说0.0。