import time start = time.process_time() 需要运行的代码 end = time.process_time() print("运行时间为%fs" %(end-start))