class Person:
num = 0
def SayHello(self):
print("Hello")
class Person:
num = 0
def SayHello(self):
print("Hello")
P = Person() #定义对象
P.SayHello()
class Complex:
def __init__(self,realpart,imagpart):
self.r= realpart
self.i = imagpart
x = Complex(3.0,-4.5)
print(x.r,x.i)
结果输出
3.0 -4.5