【发布时间】:2018-01-22 19:23:44
【问题描述】:
我的目标是在 python 中创建一个程序,它允许用户输入每米围栏的成本、围场的长度和宽度,并且程序应该计算并打印周长以及报价。我遇到了一些问题,不幸的是我对 Stack Overflow 的研究没有成功。我的代码如下(记住我只是一个初学者)
from turtle import*
print ("Welcome to the fencing quote calculator")
print ("In this program, you will be able to input the size of the padock as well as the cost of the fence per meter")
again = ""
perMetre = input(str(("Please input the cost per metre in numbers without a dollar sign")
width = input("Please input the width of the paddock in metres")
length = input("Please input the length of the paddock in metres")
perimeter = (width+2)
print ("The perimeter of this paddock is",perimeter)
cost = int((perimeter)*(perMetre))
print("{:.2f}".format(cost))
错误是 TypeError: Can't convert 'int' object to str 隐式错误代码。 如果您能用非常简单的术语解释这一点,我将不胜感激。 谢谢:)
【问题讨论】:
-
width =语句中缺少两个右括号。 -
perMetre应转换为整数或浮点数。width也是如此。也就是说,如果您使用的是 python 3
标签: python