#定义一个类 继承Process类 from multiprocessing import Process import os import time class jiecheng(Process): def __init__(self,num): Process.__init__(self) self.num = num #一算一个数的阶乘 def run(self): j = 1 for i in range(1,self.num+1): j = j * i print('%s的阶乘为:%s'%(self.num,j)) class sumToN(Process): def __init__(self,num): Process.__init__(self) self.num = num #计算一个数的累加和 def run(self): j = 0 for i in range(1,self.num+1): j = j + i print('%s的叠加求和为:%s'%(self.num,j)) if __name__ == "__main__": while True: num = input('Enter number:') num = int(num) p = jiecheng(num) #这里调用了run p.start() p = sumToN(num) p.start()