python获取系统空闲时间段

1 篇文章 0 订阅
def GetIdleDuration():
	class LASTINPUTINFO(Structure):
		_fields_ = [
			('cbSize', c_uint),
			('dwTime', c_uint),
		]
	lastInputInfo = LASTINPUTINFO()
	lastInputInfo.cbSize = sizeof(lastInputInfo)
	windll.user32.GetLastInputInfo(byref(lastInputInfo))
	millis = windll.kernel32.GetTickCount() - lastInputInfo.dwTime
	return millis

调用C++ API获取系统在无操作状态下的时间段

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
基于Python的酒店管理系统的课程设计需要实现以下功能: 1. 酒店房间信息的录入、修改、删除和查询; 2. 客户信息的录入、修改、删除和查询; 3. 预订房间和取消预订; 4. 房间入住和退房; 5. 统计酒店房间的入住率和收益情况。 以下是一个简单的基于Python的酒店管理系统的代码示例: ```python class Room: def __init__(self, room_id, room_type, price, status): self.room_id = room_id self.room_type = room_type self.price = price self.status = status class Customer: def __init__(self, customer_id, name, phone): self.customer_id = customer_id self.name = name self.phone = phone class Reservation: def __init__(self, reservation_id, customer_id, room_id, check_in_date, check_out_date): self.reservation_id = reservation_id self.customer_id = customer_id self.room_id = room_id self.check_in_date = check_in_date self.check_out_date = check_out_date class Hotel: def __init__(self): self.rooms = [] self.customers = [] self.reservations = [] def add_room(self, room): self.rooms.append(room) def remove_room(self, room_id): for room in self.rooms: if room.room_id == room_id: self.rooms.remove(room) def add_customer(self, customer): self.customers.append(customer) def remove_customer(self, customer_id): for customer in self.customers: if customer.customer_id == customer_id: self.customers.remove(customer) def add_reservation(self, reservation): self.reservations.append(reservation) def remove_reservation(self, reservation_id): for reservation in self.reservations: if reservation.reservation_id == reservation_id: self.reservations.remove(reservation) def check_room_availability(self, room_id, check_in_date, check_out_date): for reservation in self.reservations: if reservation.room_id == room_id and ((check_in_date >= reservation.check_in_date and check_in_date <= reservation.check_out_date) or (check_out_date >= reservation.check_in_date and check_out_date <= reservation.check_out_date)): return False return True def get_room_price(self, room_id): for room in self.rooms: if room.room_id == room_id: return room.price def get_room_status(self, room_id): for room in self.rooms: if room.room_id == room_id: return room.status def set_room_status(self, room_id, status): for room in self.rooms: if room.room_id == room_id: room.status = status def get_customer_name(self, customer_id): for customer in self.customers: if customer.customer_id == customer_id: return customer.name def get_customer_phone(self, customer_id): for customer in self.customers: if customer.customer_id == customer_id: return customer.phone def get_reservation_info(self, reservation_id): for reservation in self.reservations: if reservation.reservation_id == reservation_id: return (reservation.customer_id, reservation.room_id, reservation.check_in_date, reservation.check_out_date) hotel = Hotel() # 添加房间 room1 = Room(1, '单人间', 200, '空闲') room2 = Room(2, '双人间', 300, '空闲') hotel.add_room(room1) hotel.add_room(room2) # 添加客户 customer1 = Customer(1, '张三', '13888888888') customer2 = Customer(2, '李四', '13999999999') hotel.add_customer(customer1) hotel.add_customer(customer2) # 预订房间 if hotel.check_room_availability(1, '2022-01-01', '2022-01-03'): reservation1 = Reservation(1, 1, 1, '2022-01-01', '2022-01-03') hotel.add_reservation(reservation1) hotel.set_room_status(1, '已预订') print('预订成功') else: print('该房间在该时间段已被预订') # 入住 if hotel.get_room_status(1) == '已预订': hotel.set_room_status(1, '已入住') print('入住成功') else: print('该房间未被预订') # 退房 if hotel.get_room_status(1) == '已入住': hotel.set_room_status(1, '空闲') print('退房成功') else: print('该房间未被入住') # 删除客户 hotel.remove_customer(2) # 删除房间 hotel.remove_room(2) # 取消预订 hotel.remove_reservation(1) # 获取客户姓名和电话 print(hotel.get_customer_name(1)) print(hotel.get_customer_phone(1)) # 获取预订信息 print(hotel.get_reservation_info(1)) --相关问题--:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值