当我删除“通过”命令并将类留空时,它显示错误:
File "class_distance.py", line 6
point1=distance()
^
IndentationError: expected an indented block
该代码预计将计算两点之间的距离。这是代码:
import math
class distance(object):
pass
point1=distance()
point2=distance()
point1.x=input("x=")
point2.x=input("x=")
point1.y=input("y=")
point2.y=input("y=")
def main(point1,point2):
dx = point1.x - point2.x
dy = point1.y - point2.y
dist = math.sqrt(dx**2 + dy**2)
print dist
main(point1,point2)