我有一个从文件中读取信息的代码(行描述点、多边形、线和圆)并将其解析为相应的类。Point 有 x 和 7 坐标,Line 有起点和终点。
我有一个列表 ( line = ['L1','L((1,1), (1,2))','# comment']
),我试着把它排成一行。问题在于创建端点,执行时出现以下ValueError: invalid literal for int() with base 10: ''
错误x2
问题是什么?
代码:
def make_line(line):
name = line[0]
point = line[1].split(", ")
p = point[0].split(",")
x1 = int(p[0][3:])
y1 = int(p[1][:-1])
point1 = Point(x1,y1)
p = point[1].split(",")
x2 = int(p[0][1:])
y2 = int(p[1][:-2])
point2 = Point(x2,y2)
line = Line(point1,point2)
shapes[name] = line