1. 编程实现计算2023-2-1到2023-3-1相隔多少天? from datetime import datetime start_date_str = "2023-2-1" end_date_str = "2023-3-1" start_date = datetime.strptime(start_date_str, "%Y-%m-%d") end_date = datetime.strptime(end_date_str, "%Y-%m-%d") result = end_date-start_date print("result=",result,",type=",type(result)) # 当天也算一天,所以需要加一 days = result.days+1 print("days=",days) 2. 请写出房东查询订单和房客查询订单的核心代码? # 以房东的身份查询订单 # 先查询属于自己的房子有哪些 houses = House.query.filter(House.user_id == user_id).all() houses_ids = [house.id for house in houses] # 再查询预订了自己房子的订单 orders = Order.query.filter(Order.house_id.in_(houses_ids)).order_by(Order.create_time.desc()).all() # 以房客的身份查询订单, 查询自己预订的订单 orders = Order.query.filter(Order.user_id == user_id).order_by(Order.create_time.desc()).all()