Python 如何修复处理'<=';

Python 如何修复处理'<=';,python,python-3.x,Python,Python 3.x,代码应该是接收用户输入,然后将矩形移动到周围,当我运行代码时,我会得到一个Typeerror: 这里您将矩形中的属性设置为空字符串 在这里: def __init__(self, topLeft, width, height): self.__topLeft = topLeft # check width argument if (width <= 0): print("Invali

代码应该是接收用户输入,然后将矩形移动到周围,当我运行代码时,我会得到一个Typeerror: 这里您将
矩形中的属性设置为空字符串

在这里:

 def __init__(self, topLeft, width, height):
            self.__topLeft = topLeft

            # check width argument
            if (width <= 0):
                print("Invalid width")
                self.__width = Rectangle.DEFAULT_WIDTH
这里您将
矩形中的属性设置为空字符串

在这里:

 def __init__(self, topLeft, width, height):
            self.__topLeft = topLeft

            # check width argument
            if (width <= 0):
                print("Invalid width")
                self.__width = Rectangle.DEFAULT_WIDTH

will=Rectangle(topLeft=“”,width=“”,height=“”)
为什么要创建一个宽度和高度为空字符串的矩形?这毫无意义。
will=Rectangle(topLeft=“”,width=“”,height=“”)
为什么要尝试创建一个宽度和高度为空字符串的矩形?这没有任何意义。我把它留空是因为它应该可以从用户那里获取输入,但我想我错过了应该具有请求该输入的方法的那部分。无论哪种方式,都需要将
int
float
传递给构造函数,而不是字符串。或者你也可以在类内将字符串转换成数字。我如何将int或float传递给构造函数,以便它是必需的?不确定我是否理解你的意思,我将其留空,因为它应该可以从用户那里获取输入,但我想我错过了应该具有要求该输入的方法的部分。或者这样,您需要将
int
float
传递给构造函数,而不是字符串。或者你也可以在类内将字符串转换成数字。我如何将int或float传递给构造函数,以便它是必需的?不确定我理解你的意思
bill = Point(x="", y="")
will = Rectangle(topLeft="", width="", height="")
 def __init__(self, topLeft, width, height):
            self.__topLeft = topLeft

            # check width argument
            if (width <= 0):
                print("Invalid width")
                self.__width = Rectangle.DEFAULT_WIDTH
bill = Point(x=5, y=9)
will = Rectangle(topLeft=2, width=4, height=1)