写入用户注册信息的时候可以直接取出信息 def write_info(user,pwd,phone,email): aaaa = time.strftime('%Y-%m-%d-%H-%M-%S', time.localtime(time.time())) Session = sessionmaker(bind=engine) session = Session() obj = Users(user_name=user, user_pwd=pwd, user_phone=phone,user_email=email,user_time=aaaa) session.add(obj) # 写入直接拿出来 session.flush() session.refresh(obj) print(obj.user_nid,obj.user_email,obj.user_time) session.commit()