错误:浮动对象不可调用

时间:2016-01-30 18:07:56

标签: python

while True:
    print("ʘʘʘʘʘʘʘʘʘʘʘʘʘʘʘʘ")
    print("ʘUnit Converterʘ")
    print("ʘʘʘʘʘʘʘʘʘʘʘʘʘʘʘʘ\n")
    print("This program is used to convert units for height and weight.")

    measurement = input("Would you like to convert height or weight?; ")

    if measurement == ("height"or"Height"or"h"or"H"):
        units = input("What units do you want to convert from?(metres/inches); ")

        if units[0] == ("m"):
            numberm = float(input("Please enter your height in metres; "))
            inchfm = (numberm * 39.37)
            inchfm = float(inchfm)
            print = (inchfm)

我如何让它工作?任何答案将不胜感激。

2 个答案:

答案 0 :(得分:1)

以下是一些问题:

  1. measurement的比较无法正常工作:

    if measurement == ("height"or"Height"or"h"or"H"):
    

    这将首先评估("height"or"Height"or"h"or"H"),其评估结果为"height"。所以它相当于:

    if measurement == "height":
    

    要执行预期的操作,您需要使用:

    if measurement == "height" or measurement == "Height" or measurement == "h" or measurement == "H":
    

    更简洁的方法是:

    if measurement in ("height", "Height", "h", "H"):
    
  2. print语句只是对名为print的变量的赋值:

    print = (inchfm)
    

    将其更改为:

    print(inchfm)
    

答案 1 :(得分:0)

该计划应该做什么?在你的问题中包括。

无论如何......试试这个......我纠正了一些问题:

SELECT TOP(@limit)PERCENT