今天编程遇到了一段代码,现在截取如下以作解释:
if isinstance(startPoint, Point) and isinstance(endPoint, Point):
self.startPoint = startPoint
self.endPoint = endPoint
else:
self.startPoint = Point(*startPoint)
self.endPoint = Point(*endPoint)
在else分支当中出现了*,那么在python中*和**有什么用法呢?
一个星(*):表示接收的参数作为元组来处理
两个星(**):表示接收的参数作为字典来处理