class vector3: def __init__(self, x_ = 0, y_ = 0, z_ = 0): #构造函数 self.x = x_ self.y = y_ self.z = z_ def __add__(self, obj): return vector3(self.x+obj.x, self.y+obj.y, self.z+obj.z) def __sub__(self, obj): return vector3(self.x-obj.x, self.y-obj.y, self.z-obj.z) def __mul__(self, obj): return vector3(self.x*obj.x, self.y*obj.y, self.z*obj.z) def __pow__(self, obj): return vector3(self.y*obj.z-obj.y*self.z, self.z*obj.x-self.x*obj.z, self.x*obj.y-obj.x*self.y) def __str__(self): return str(self.x)+','+str(self.y)+','+str(self.z) v1 = vector3(1, 2, 3) v2 = vector3(0, 1, 2) print (v1 + v2) print (v1 - v2) print (v1 * v2) print (v1 ** v2)