Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TypeError:/:';str';和';int';Python 2.7_Python_Python 2.7_Error Handling - Fatal编程技术网

TypeError:/:';str';和';int';Python 2.7

TypeError:/:';str';和';int';Python 2.7,python,python-2.7,error-handling,Python,Python 2.7,Error Handling,您能告诉我为什么“hourlypay”有错误。原始输入函数返回一个字符串。您需要将其强制转换为int或float,然后才能将其用于数学运算,如hourlypay=salary/(52-vactaion)*tax/40 不过,这样做很简单,只需将其替换为 name = raw_input("What is your name?") salary = raw_input("What is your annual salary?") tax = float(raw_input("What is y

您能告诉我为什么“hourlypay”有错误。

原始输入函数返回一个字符串。您需要将其强制转换为int或float,然后才能将其用于数学运算,如
hourlypay=salary/(52-vactaion)*tax/40

不过,这样做很简单,只需将其替换为

name = raw_input("What is your name?")

salary = raw_input("What is your annual salary?")

tax = float(raw_input("What is your tax rate? (Convert it to decimals)"))

vactaion = int(raw_input("How many not paid vacation weeks do you have?"))

hourlypay = salary / ( 52 - vactaion ) * tax / 40 

print " %, your hourly pay after taxes is %." % ( name, hourlypay), 
你是在下一行做的,所以看起来你知道怎么做。在这种情况下,这是调试代码的问题。当您遇到错误时,在将其发布到此处之前,请仔细检查代码中的每一行,尤其是错误消息中涉及的内容。我相信只要再努力一点,你就可以自己抓住这个机会,节省很多时间

salary = float(raw_input("What is your annual salary?")