首先导入时间(time)模块;然后在需要等待执行的命令前调用sleep()方法,并在方法的括号里将等待时间设置为想要的秒数即可。import timeprint '5秒前'time.sleep(10)print '5秒后'