当前位置: 首页 > news >正文

国内外优秀设计网站做网站用别人的源码可以吗

国内外优秀设计网站,做网站用别人的源码可以吗,wordpress获取4条文章标题,拼多多网站文章目录 第1关#xff1a;字符串、列表与集合第2关#xff1a;哈希与有序集合第3关#xff1a;Redis基本事务与其他命令 第1关#xff1a;字符串、列表与集合 编程要求 根据提示#xff0c;在右侧Begin-End区域补充代码#xff0c;完成任务分配的后端处理逻辑#xff… 文章目录 第1关字符串、列表与集合第2关哈希与有序集合第3关Redis基本事务与其他命令 第1关字符串、列表与集合 编程要求 根据提示在右侧Begin-End区域补充代码完成任务分配的后端处理逻辑 在 task_empty() 方法中 从 Redis 中获取列表 task_list 的长度判断是否为 0 若为 0则返回 True 若不为 0则返回 False 在 get_task() 方法中 从列表 task_list 的最右侧弹出一个元素赋值给 task 将 task 的值设置到 Redis 的字符串键 current_task 中 在 get_unallocated_staff() 方法中 从集合 unallocated_staff 中随机返回一个元素赋值给 staff 将上面的 staff 从集合 unallocated_staff 移动到集合 allocated_staff 中 返回returnstaff 的值 在 allocate_task(staff) 方法中 将参数 staff 的值追加到 Redis 字符串键 current_task 的尾部中间以 : 间隔 将追加后的字符串键 current_task 从左侧推入列表 task_queue 将字符串键 current_task 的值设置为 “None” 测试说明 我会对你编写的代码进行测试 测试输入 task_1 task_2 task_3 task_4 task_5 staff_1 staff_2 staff_3 staff_4 staff_5 预期输出 Init task list: [‘task_1’, ‘task_2’, ‘task_3’, ‘task_4’, ‘task_5’] Init staff list: set([‘staff_4’, ‘staff_5’, ‘staff_1’, ‘staff_2’, ‘staff_3’]) Cur task list is empty: False Get new task: task_5 Current staff is allocated: True Current staff is unallocated: False Current task is: None Allocated all tasks Task queue length: 5 Task list is empty: True Allocated_staff: set([‘staff_4’, ‘staff_5’, ‘staff_1’, ‘staff_2’, ‘staff_3’]) Unallocated_staff: set([]) 代码示例如下 #!/usr/bin/env python #-*- coding:utf-8 -*-import redisconn redis.Redis()def task_empty():# 请在下面完成判断任务列表是否为空#********* Begin *********#return int(conn.llen(task_list))0#********* End *********#def get_task():# 请在下面完成获取一个任务#********* Begin *********#task conn.rpop(task_list)conn.set(current_task,task)#********* End *********#def get_unallocated_staff():# 请在下面完成获取一个未分配的员工#********* Begin *********#staffconn.srandmember(unallocated_staff)conn.smove(unallocated_staff,allocated_staff,staff)return staff#********* End *********#def allocate_task(staff):# 请在下面完成分配任务#********* Begin *********#conn.append(current_task,:str(staff))conn.lpush(task_queue,conn.get(current_task))conn.set(current_task,None)#********* End *********# 第2关哈希与有序集合 编程要求 根据提示在右侧Begin-End区域补充代码完成带优先级的队列系统的后端处理逻辑 在 set_task_info(task_id) 方法中 使用参数 task_id 作为域初始状态 “init” 作为值构成域-值对存放在 task_status 哈希键中。 在 add_task_to_queue(task_id, priority) 方法中 参数说明 task_id 为任务 ID priority 为任务优先级。 将分值优先级为 priority 的成员 task_id 存入有序集合 task_queue 中。 注意将参数 priority 转换为整型 调用 set_task_info() 方法传入参数 task_id 在 get_task() 方法中 新建变量 task_list_by_priority值为 使用 ZREVRANGE 命令按照分值优先级从大到小顺序返回有序集合 task_queue 的全部成员。 新建变量 current_task值为 task_list_by_priority 中的第一个元素下标为 0 将成员 current_task 从有序集合 task_queue 中移除 修改哈希 task_status 中的 current_task 域的值为 “processing” 返回returncurrent_task 的值 测试说明 我会对你编写的代码进行测试 测试输入 1 2 3 4 5 6 7 8 9 10 2 4 9 1 0 5 8 6 7 3 预期输出 Add new task: 1, priority: 2, status: init Add new task: 2, priority: 4, status: init Add new task: 3, priority: 9, status: init Add new task: 4, priority: 1, status: init Add new task: 5, priority: 0, status: init Add new task: 6, priority: 5, status: init Add new task: 7, priority: 8, status: init Add new task: 8, priority: 6, status: init Add new task: 9, priority: 7, status: init Add new task: 10, priority: 3, status: init Before: task list is: [‘3’, ‘7’, ‘9’, ‘8’, ‘6’, ‘2’, ‘10’, ‘1’, ‘4’, ‘5’] Get new task: 3 After: task list is: [‘7’, ‘9’, ‘8’, ‘6’, ‘2’, ‘10’, ‘1’, ‘4’, ‘5’] Current task status: processing 代码示例如下 #!/usr/bin/env python #-*- coding:utf-8 -*-import redisconn redis.Redis()# 初始化任务信息到 Redis 中 def set_task_info(task_id):# 请在下面完成要求的功能#********* Begin *********#conn.hset(task_status,task_id,init)#********* End *********## 将任务添加至任务队列 def add_task_to_queue(task_id, priority):# 请在下面完成要求的功能#********* Begin *********#conn.zadd(task_queue,task_id,int(priority))set_task_info(task_id)#********* End *********## 从任务队列中取出优先级最高的任务 def get_task():# 请在下面完成要求的功能#********* Begin *********#task_list_by_priorityconn.zrevrange(task_queue,0,-1)current_tasktask_list_by_priority[0]conn.zrem(task_queue,current_task)conn.hset(task_status,current_task,processing)return current_task#********* End *********# 第3关Redis基本事务与其他命令 编程要求 根据提示在右侧Begin-End区域补充代码完成网络约车的后端处理逻辑 在 request_cab(user_id, priority) 方法中 判断是否存在哈希键 request:info:用户ID 的 time 域 提示可使用 HEXISTS 命令 若存在则直接 return 若不存在做如下操作 使用事务提交下列命令 将参数 user_id 从最左侧推入列表 cab:queue 使用 HMSET 命令设置哈希键 request:info:用户ID: 域 time值为 time.time() 域 priority值为参数 priority 将上述哈希键的过期时间设置为 10分钟 在 allocate() 方法中 使用 SORT 命令对列表 cab:queue 排序并将结果赋值给 cab_queue 使用 BY 参数 参考键为哈希键 request:info:*其中 * 为占位符 使用上述参考键中的 priority 域 使用 DESC 参数做倒序排序 取出 cab_queue 的第一个元素下标为 0赋值给 current_respond 从列表 cab:queue 中移除变量 current_respond 中包含的元素 返回returncurrent_respond 测试说明 我会对你编写的代码进行测试 测试输入 1 2 3 4 5 6 7 8 9 9 8 7 6 5 4 3 2 1 预期输出 Receive new request: 1, priority: 9, is_expired? True Receive new request: 2, priority: 8, is_expired? True Receive new request: 3, priority: 7, is_expired? True Receive new request: 4, priority: 6, is_expired? True Receive new request: 5, priority: 5, is_expired? True Receive new request: 6, priority: 4, is_expired? True Receive new request: 7, priority: 3, is_expired? True Receive new request: 8, priority: 2, is_expired? True Receive new request: 9, priority: 1, is_expired? True Before: request queue: [‘1’, ‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’] Allocate new request: 1 After: request queue: [‘2’, ‘3’, ‘4’, ‘5’, ‘6’, ‘7’, ‘8’, ‘9’] Repeat request in few seconds: Before: request queue length: 8 After: request queue length: 8 代码示例如下 #!/usr/bin/env python #-*- coding:utf-8 -*-import time import redisconn redis.Redis()# 用户端发起派车请求 def request_cab(user_id, priority):# 请在下面完成要求的功能#********* Begin *********#if conn.hexists(request:info: str(user_id), time):returnpipe conn.pipeline()pipe.lpush(cab:queue, user_id)pipe.hmset(request:info:str(user_id), {time: time.time(), priority:priority})pipe.expire(request:info: str(user_id), 10 * 60)pipe.execute()#********* End *********## 平台选择优先级最高的派车请求并派车 def allocate():# 请在下面完成要求的功能#********* Begin *********#cab_queueconn.sort(cab:queue,byrequest:info:*-priority,descTrue)current_respondcab_queue[0]conn.lrem(cab:queue, current_respond, 1)return current_respond#********* End *********## 用户端取消派车请求 def cancel_cab(user_id):conn.expire(request:info: str(user_id), 0)conn.lrem(cab:queue, user_id)
http://www.huolong8.cn/news/37164/

相关文章:

  • 建设一中校园网站马鞍山网站建设咨
  • 银川网站开发培训阿里云域名注册优惠口令
  • 仿网站源码北京网站建设策划建设公司
  • 百度网站推广怎么做网站程序开发外包
  • 电子商务网站建设技术基础--asp.net程序设计教学大纲wordpress主题中文
  • ps可以在哪个网站上做兼职制作图片的软件哪个好用
  • 电子科技企业网站建设购物网站开发含代码
  • 福建省建设厅网站余腾龙官方网站做号软件
  • 网站解析 cname抖音小程序源码
  • 做餐饮企业网站的费用代运营的工作内容
  • 网站建设教程试题网站建设项目国内外分析报告
  • 网站制作收费明细表潍坊快速建站模板
  • 长春企业网站模板建站为企网站
  • ssh小型购物网站开发网络平台营销
  • 建设银行网站网址是什么手机网站首页布局设计
  • 做家庭影院的有哪些网站广州网络运营课程培训班
  • 做产品网站建设网站建设需要了解哪些方面
  • 那些网站h5做的不错国内网页设计师个人网站
  • 岳池网站建设互联网运营公司排行榜
  • 自助业务网站系统湖南营销型网站建设 要上磐石网络
  • 定制开发网站 推广兰州网站建设推荐q479185700上快
  • 商务网站建设的组成包括微软网站制作软件
  • 网站语音转写怎么做中国建设工程监理协会网站
  • 如何做jquery音乐网站延安网站建设哪家专业
  • 怎么用mvc架构做网站微信小程序开发和网站开发的区别
  • 网站的大图标怎么做的example邮箱注册网站
  • 网站投票链接怎么做哪些人可以做网站
  • 网站建设推广西安app开发
  • 做网站开发的应选什么专业义乌seo快速排名
  • 网站按关键词显示广告图片无后台基础怎么建设网站